Quote: "Yrd you should use the formula Julio gave you on the Newton forum, and apply the force with the custom gravity functions (NDB_BodySetGravity, NDB_NewtonBodySetForceAndTorqueCallback)
"
his function was not usefull or at least it seems it was.
F = m (v – v0) / dt
v is the magnitud of the velocity you want.
v0 is the magnitud of body velocity
dt is the simulation time step.
F is the magnitud of the force you need to apply to the body.
first i dont know the velocity i want. im adding impulse. not setting velocity.
second i got this example to try.
You can use Julio's method of
F = (v - v0) / dT
dT is the frame time. Basically, if no impulse is applied to the plane, just store the current velocity at each frame. And on the next frame, just use the previous frame's velocity to be your NEW desired velocity. That way you can be sure that the plane will never slow down unless acted upon by another force. You'll essentially be adding on any lost energy between the previous frame and the new one.
Code:
PSEUDOCODE
// If no impulse or acceleration is acting on the plane
// we'll add back the lost force.
if (plane.Acceleration.Magnitude() == 0)
{
// Get plane's new velocity, with lost energy
Vector vCurrent = plane.GetVelocity ();
// In case the plane is turning, we'll need the NEW velocity
// direction, but the OLD magnitude. This will tell us what our
// desired velocity is.
Vector vLastFrame;
vLastFrame = plane.GetVelocity (); // Current velocity
vLastFrame.Normalize (); // Normalize (only dir is needed)
// Here we multiply the current direction by the old magnitude
// to get the previous velocity vector.
vLastFrame *= fPreviousVelocityMagnitude;
// Calculate the force to be added back
Vector vForce = plane.mass *
(vLastFrame - vCurrent) / fTimeStep;
// Reapply lost force
plane.AddForce (vForce);
}
// ... Do the usual stuff...
// Store current velocity magnitude regardless of the plane's
// acceleration. When impulses aren't applied, we'll need it
// to add back the lost energy.
fPreviousVelocityMagnitude = plane.Velocity.Magnitude ();
this also usen the idea abouve. but it looks like you will need to set velocity. hence will then have a object they acts like it has a infident mass. meaning will push anything out of its way. losen all physic's
this cuold be soulved bye adding impulse to counter the lost engery instead of doing a "NDB_NewtonBodySetVelocity body + lost"
but i dont know how to convert impulse into velcity.
last why do you say to "and apply the force with the custom gravity functions (NDB_BodySetGravity, _NewtonBodySetForceAndTorqueCallback)"
why not just impulse?
i know im becoming very anoying ive been askibng for help on this for 3 weeks now..