Hi, I'm making a game involving a ball and some walls - the walls need to be intransigent and unaffected by gravity and each other. So at first thought I made them with zero mass and kinematic type. But it seems impossible to set velocity (linear or angular) on them. I'm not trying to add/apply forces (because they have 0 mass, I understand that is not going to work), but I just want to set their velocity, and nothing happens. I can set their world transform no problem, but any attempt to set velocity just has no effect (even if I set the right flags to make sure they're not going inactive).
What am I doing wrong/what do I need to change?
Thank you.
Intransigent Bodies - Still need to be able to set velocity
-
- Posts: 14
- Joined: Fri Jun 26, 2015 4:59 pm
- drleviathan
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: Intransigent Bodies - Still need to be able to set veloc
Kinetic objects are not moved by the DynamicsWorld itself. Instead you need to give them a btMotionState (a custom derived version of course, since that is just a pure virtual interface class) that provides the new worldTransform whenever btMotionState::getWorldTransform() is called. Also, you need to make sure the object is active since the DynamicsWorld only calls that on active kinematic objects. There is a relevant wiki page.
Setting the velocity of a kinematic object merely ensures that colliding objects pick up the proper velocity contribution at contact.
Setting the velocity of a kinematic object merely ensures that colliding objects pick up the proper velocity contribution at contact.
-
- Posts: 14
- Joined: Fri Jun 26, 2015 4:59 pm
Re: Intransigent Bodies - Still need to be able to set veloc
Thanks for the reply. So I need to set the velocity in order to ensure correct collision behaviour but then handle setting the world transform myself (according to that velocity). Gotcha. Thanks.