Different body types

jchmack

05-05-2007 21:05:10

Im sure i understand what a Static/dynamic body is. But what is the Difference between a kinematic and static body? what does mbody->setkinematic do? it seems to just turn a body static. The tutorials explain static/dynamic bodies quite well but only show how to make a body kinematic not really telling what it does exactly.

betajaen

05-05-2007 21:33:48

It's just a dynamic body that has a flag (it can be turned on or off) and not permanent. It's best to think it as a body in between dynamic and static bodies; it ignores all collision responses (but other things can collide with it), and it will not react to forces such as gravity and momentum, but unlike static bodies; kinematic bodies can be directly moved around, and the other bodies will respond to it moving.

The Character Controller is a kinematic body, with a bit of helper code in between.

betajaen

05-05-2007 21:46:48

I thought up a good comparison - The SNES Mario games:

- Mario and the Enemies are character controllers.
- The tortoise shells and those fireballs that mario gets from time to time, are dynamic bodies
- The moving block that go up and down, or right across the screen are kinematic bodies
- The ground and other parts of the level are static bodies.

jchmack

05-05-2007 22:44:09

ahh but how come when i try to move my kinematic body

mBody = mScene->createBody
(
name,
Mesh,
new meshShape(Mesh),
1,
InitialPosition
);

mBody->setKinematic(true);

Velocity = InitialDirection * Velocity;
mBody->setLinearVelocity(Velocity);


it doesn't move?

betajaen

05-05-2007 23:02:48

Nope. Doesn't response to forces.

mBody->setGlobalPosition(...);
mBody->setGlobalOrientation(...);

jchmack

05-05-2007 23:26:16

well im trying to create something like an elevator/lift. the player needs to be able to "ride" it as it goes up. at first i tried to use a static body but no moving. I haven't tried it yet but i bet if i use a kinematic with these:

mBody->setGlobalPosition(...);
mBody->setGlobalOrientation(...);

then the lift would be teleporting every frame and my character would fall through. Especially at low frame rates.

i tried using a kinematic because of your mario example

- The moving block that go up and down, or right across the screen are kinematic bodies.

and statics cant move at all so im betting they are out.

so i guess ill try a dynamic with a high density.

betajaen

06-05-2007 00:06:11

A Dynamic body set as kinematic should be fine, as long as the movement is slow and you have CCD enabled. It'll be fine. But I have no idea how or if kinematic and kinematic bodies collide at all, or if they do the behaviour. The whole concept of FXScenes use kinematic bodies, and they work perfectly.

You could pull it off a different way; Duplicate how it works in real-life. A flatish cube to represent the base, connected to a pulley joint connected to a counter weight. You freeze the movement of the lift body to everything except Y.

jchmack

06-05-2007 00:57:50

A Dynamic body set as kinematic should be fine, as long as the movement is slow and you have CCD enabled. It'll be fine.


when you say this do you mean that i should reposition the kinematic myself each frame like i said via:

mBody->setGlobalPosition(...);
mBody->setGlobalOrientation(...);

or you mean that there is some way im missing?

betajaen

06-05-2007 09:52:50

Yep, every frame.

jchmack

06-05-2007 18:06:51

hmm im trying this and it works if my characters are moving but not if they are just standing there. I might just have to change the characterstate to always be moving/simulating.