(Magnitude of vector)*x SHOULD EQUAL magnitude of (vector*x)

(Velocity is a vector3)

velocity*=rayHit.distance/velocity.magnitude;

print(velocity.magnitude==rayHit.distance);

These two lines of code should ALWAYS print true, shouldn’t they? I guess not, because I get false sometimes. Anybody know why?

You can’t ever count on any float to == any other float, that’s just how it is when you are working with float values. You should check to see if the absolute value of one minus the other is less than .0001, if so, consider them equal.

Or you can use this:

Mathf.Approximately (velocity.magnitude,rayHit.distance)