This had me stuck for days, any help would be super appreciated
Making a rocket game, and long story short I need to freeze the rocket GameObject within the scene, but still calculate what its velocity and acceleration would were it still moving.
To do this I had hoped to just rearrange F = MA, using the force of the engines and mass of the rocket to find acceleration, and use that to derive the velocity, but this seems to give values far lower than when the rocket does move throughout the scene and I just use rigidbody.velocity to find acceleration, after applying force to it the normal way…here’s my code
rb2d.AddForce(new Vector2(xForce, yForce), ForceMode2D.Impulse);
Using this to apply force, and calculating acceleration using…
newTime = Time.time;
newVelocity = rb2d.velocity.magnitude;
acceleration = ((newVelocity - oldVelocity) / (newTime - oldTime));
oldTime = newTime;
oldVelocity = newVelocity;
//calculates the acceleration by dividing the change in speed by change in time
return acceleration;
I get a value of about 16 ms^-2, but when I freeze the GameObject, and calculate it’s acceleration using
stasisAcceleration.x = xForce / rb2d.mass;
stasisAcceleration.y = (yForce / rb2d.mass) - Physics2D.gravity.y;
NB: xForce and yForce are exactly the same value as before
I get a much smaller value, in fact the value I get is around -0.2ms^-2, as it thinks the acceleration due to gravity is the greater than the acceleration due to the yForce.
What am I doing wrong here? Why is my manual calculation for acceleration giving a value way lower than it should be?
Thanks in advance ![]()
Fred T.A