In the manual I read that kinematic bodies do not collide with static ones. I find this strange, what is exactly the use of having both static and kinematic bodies then? I thought the usual set-up was to have the world (walls) made up by static bodies and have a character that is a kinematic body. That way you have pretty good control over your character while it still collides with walls.
kinematic vs. static collision
General DiscussionBy definition, kinematic bodies have infinite mass, and so do static bodies. Newton's laws are undefined for two infinite mass bodies.
Of course, you're right.
So the character needs to be dynamic. What's the best way to move him while keeping strict control? Changing linear veloctiy on a dynamic body isn't encouraged, right? But applying forces and such feels so... indirect?
So the character needs to be dynamic. What's the best way to move him while keeping strict control? Changing linear veloctiy on a dynamic body isn't encouraged, right? But applying forces and such feels so... indirect?
Maybe you didn't noticed, but almost every game character isn't controlled "directly". They usually apply a force to the body, with a high friction (to make sure the character stops fast). For example (and just one over nine thousand 😛), Counter Strike: Source.
For my game, I make a lot of objects dynamic sensors.
That way, they register collisions, but you still have direct control over motion.
Usually, for any given pair of direct controlled colliding objects, only one of them actually needs to be solid. The other one can safely be replaced with a dynamic sensor.
That way, they register collisions, but you still have direct control over motion.
Usually, for any given pair of direct controlled colliding objects, only one of them actually needs to be solid. The other one can safely be replaced with a dynamic sensor.
Thanks for your replies, that cleared things up.
As a follow up to the original question, how hard would it be to obtain contact/collision information between kinematic bodies and static bodies? I use Begin/EndContact in the contact listener but they don't receive contacts between kinematic and static bodies, probably because they don't need contacts 🙂
I could add collision between static-static, static-kinematic, and kinematic-kinematic. But that would slow down the simulation for everyone else. Most likely you have a special case. For that you can use b2World::Query and b2TestOverlap.
Original thread: https://box2d.org/forum/viewtopic.php?t=5360