Hi.
Ok, found the problem, or rather problems...
First you are adding a constant force of 9.8 inside the ForceAndTorque callback, but you forgot to set the world gravity to zero so your are basically adding twice the gravity to the NewtonBody.
The world is already adding a gravity force to all bodies.
I realized this when logging the distance the bodies travelled after 3 seconds.
The newton body had travelled 88 units which is twice the expected 44 units.
But I also noticed your "manual" body had only travelled 30 units in the same time the Newtonbody had travelled 44 units.
It had to do with the Time.fixedtime you were using. The default fixed timestep in Unity is 0.02(50 fps) and Newton is running at 0.016(60 FPS).
Try changing your code to this...
- Code: Select all
static float fixedTime = 0;
override public void OnApplyForceAndTorque(float timestep)
{
fixedTime += timestep;
body.GetBody().AddForce(0, 0, Ftraction.z);
//kineticcube.transform.position= new Vector3(0f, 0f, Time.fixedTime * Time.fixedTime * g / 2);
kineticcube.transform.position= new Vector3(0f, 0f, fixedTime * fixedTime * g / 2);
}