[Resolved] Shaking physics body while creating/removing physics body

Every frame, I’m using the following code to remove and create a physics body (60 fps) because apparently you can’t directly control a physics body’s size. However, the ball starts shaking back and forth a few pixels as it grows, rather than increasing in size fluidly. I need it to be a dynamic body. Thoughts? thanks.

[code]
–Grow ball
if growBall == true then

physics.removeBody( shooterball )
shooterball.width = shooterball.width*1.1
shooterball.height = shooterball.height*1.1
physics.addBody ( shooterball, { radius = shooterball.width/2})

end
[import]uid: 161435 topic_id: 28451 reply_id: 328451[/import]

I found a work around using an invisible physics object, so it is functional, but I’m still curious why this was happening.

EDIT: I discovered what was happening: the engine can’t seem to delete the previous body and create a new one fast enough, so the object was literally colliding with itself. When I added a line to make the body a sensor, then remove it, then create a new one, it fixed the issue. [import]uid: 161435 topic_id: 28451 reply_id: 114950[/import]

Hey Andrew,

Well done on solving the issue - thanks so much for posting an update to this, it could really help others :slight_smile:

Peach [import]uid: 52491 topic_id: 28451 reply_id: 115048[/import]