Rigidbody speed calculations not equal to frames per second?

Recently I’ve been focusing on Vector maths, find a vector along a line, etc… So I’m trying to calculate different speeds between two objects that they meet at a point. And upon refactoring my “Speed” calculations, I’m noticing something that doesn’t make sense…

float forceToAdd = 4000f; // rb.AddForce(forward * 4000f)
float speedPerSecond = forceToAdd / 50f;
float distancePerFrame = speedPerSecond / 50f;
// targetFPS = 60;

^ This is basically the summed up version of what the math is doing.

After researching, all speed correlations in Unity use Units/perSecond, which can be called meters, or whatever you so choose. I get that, it’s just a form of measurement. But how in the world are the calculations going by fractions of 50, when the target frame rate is a solid 60?

If you’re curious to what the code looks like to get the results:

float lifetime = Vector3.Distance(fromPosition, trans.position); // gives 1.6 a frame
float rbSpeed = Mathf.Round(rb.velocity.magnitude); // gives 80 @ 4000 force
print($"{name} is rbSpeed {rbSpeed} @ lifeTime {lifetime}");

As lifetime just gives the distance from the start position each frame, in this equation is “1.6”, and rbSpeed is giving “80”… 4000 / 50 = 80, 80 / 50 = 1.6…

Is there something I’m missing, within the hard code of unity? Or should I just not care, and move on about my day? Or would this have more to do with calling this math within Update(), and not FixedUpdate()?

  • I would still need each frame to calc properly, regardless if fixed update gives correlations to 60.

It was actually the mass, causing the issue. As changing the mass to 2 gave the results of:

units per second = 40;
units per frame = 0.8;

Very interesting to know, as I thought mass was only physics changing in at least a value of 10-100. Learn something new everyday :slight_smile: