-a kinematic body does not move by applying forces.
-they can move by setting the velocity, which is used by the solver to move them
-they can move by setting position, by the solve does not know about changes of positions.
-if you attach a joint to a kinematic body, the joint will calculate the force needed to move both bodies
but since a kinematic body does not move by forces, what you get is one body moving while the kinematic state put.
this is what you see in the demo. the picking code, does not uses forces or velocity to move the picked body, it attaches a kinematic joint.
there are good reasons for that. among them.
1-using a joint, uses the engine for doing all the calculation of converting changes of position to impulses.
2-it works better when picking objects that are part of a contraction of bodies. because is calculates the forces that propagate to those other bodies.
but it is not perfect, because as you can see, if a kinematic body is attached to dynamics body, the joint will never be able to move the kinematic body.
fixing the picking code, so that convert the pick kinematic bodies by calculation the velocity,
only fix part of the problem.
if the app picks the kinematic body and apply the velocity, it will move correctly because the solver will see the velocity, so attached bodies will also move.
but if the app picks an attached dynamics body, now it does not know that the body was attached to a kinematic body, so the din body will move, but the kinematic will remind put.
this is why I said that the best way in to encapsuled the bodies and joint int a model, and use an invDynamic solve to predict the motion and use that to set the velocity of the kinematic body.
it is also why I asked what you were doing, because I did not think you were doing that kind of stuff.
if you want to just move the kinematic body, just set the velocity, and it should bode everything.
and again, dynamics bodies attach to kinematic body do not affect the kinematic body.
basically, it can state as:
Kinematic bodies are one way interaction objects, they affect dynamics bodies but dynamic bodies do not affect them.
are you try to attach dynamics bodies to the plane?
if so, them using a kinematic body may not be the best solution.
there are other ways.
you can use a dynamics body.
then in the notify call back, give a force and torque callback that translate the conversion of the changes in the trajectory to impulses.
that is, in each frame once you calculate:
- Code: Select all
v to move from p(body) to p(plane)
w to move from q(body) to q(plane)
you can calculate a Linear and angular impulse.
- Code: Select all
LinearImpulse = (v - v(body)) * inverseMass
angularImpulse = (w - w(body)) * inverseInertia
them use the function on the dynamics body to apply the impulse to the dynamic body representing the plane.
this is how was done in 3.xx, and I believe the will probably be simpler for you.
The plane will be a dynamics body and will work with everything that you are used to.
so it will be a full physics object.
they only this is that as Joe said, there will be a small lag, between the physics and the plane simulation. This is because, physics are subject to their one inertia, so impulses so impulse cannot change their trajectory in finite time.
but of you make the body representing the plane sufficiently massive, they the attached bodies will fallow with negligible lag.