Box2D ApplyForce/Impulse?

Monkey Forums/Monkey Programming/Box2D ApplyForce/Impulse?

CopperCircle(Posted 2012) [#1]
Hi, I have been playing with box2d and can't get ApplyForce/Impulse to do anyting, i am using like this:

playerEntity.body.ApplyImpulse(New b2Vec2(0, -50), playerEntity.body.GetPosition())

But nothing happens, SetLinearVelocity works but Force/Impulse do nothing...?

Thanks.


muddy_shoes(Posted 2012) [#2]
ApplyImpulse definitely works because I'm using it. Could be an issue with the impulse scale compared to the mass of your object.


CopperCircle(Posted 2012) [#3]
Thanks, I had not set the Mass Data at all, after adding this, Force/Impulse works :)

Local massdata:b2MassData = New b2MassData()
massdata.center = New b2Vec2(0,0)
massdata.mass = 1.0
massdata.I = 0.0
playerEntity.body.SetMassData(massdata)

One more question, how do you get a sphere to bounce with the same velocity of its impact? I have set the restitution to 1.0 and there is a small bounce but I was aiming to get it to keep bouncing continuously..?


muddy_shoes(Posted 2012) [#4]
You've set the restitution of the thing your entity is hitting to 1.0 or the entity? I set my static bouncy platforms to have a restitution of 1.0 and the player avatar to 0.3.


CopperCircle(Posted 2012) [#5]
Thanks, I had both set to 1, reducing the player to 0.3 helps.