I have a dynamic platform which is moved by the keyboard. Think brick breaker games. I want it to reflect other dynamic objects that hit it, but I don't want it to get knocked all over the place. How do I do that?
Appreciate the help. Thanks.
I have a dynamic platform which is moved by the keyboard. Think brick breaker games. I want it to reflect other dynamic objects that hit it, but I don't want it to get knocked all over the place. How do I do that?
Appreciate the help. Thanks.
You can make the platform a kinematic body. Set the type to b2_kinematicBody in the body definition before you create it, or do body->SetType(b2_kinematicBody) after you create it.
Kinematic bodies do not respond to forces or impulses, so you will need to use SetLinearVelocity to move it. They also do not collide with static bodies so if you have static-body walls at the side of your playing area, the platform will be able to move right through them - you'll have to check the position each time step to see if the platform should stop.