- Home /
Can someone explain what is Rigidbody.GetRelativePointVelocity(Vector3 relativePoint) ?
I understand GetPointVelocity as this : if the rigidbody only has linear velocity, the function will return the same value as rigidbody.velocity. But if it is rotating, then it will consider angularVelocity as well. In which case a point farther from the centre of mass will have a higher value. But i don't understand what GetRelativePointVelocity. Even in the documention, the explaination isn't clear and the example actually doesn't use GetRelativePointVelocity but instead uses GetPointVelocity(transform.TransformPoint(localPoint)). So i thought they are both same but they are giving different values. Can someone explain with an example what it is.
Answer by Bunny83 · 5 days ago
Don't use "GetRelativePointVelocity" as it contains an error and is unusable. I've explained the issue over here in the bottom half..
Unity's "GetRelativePointVelocity" method actually mix local and world space velocities. It calculates the localspace tangential velocity based on the angular velocity and adds the worldspace linear velocity. The result just makes no sense at all.
The concept of a local space velocity only makes partially sense. When you have a rotating motion the velocity would constantly change direction / magnitude if it's combined with linear velocity. Rotating motions are really hard to grasp. If you have a wheel rolling downhill, from worldspace point of view it looks like the bottom point is standing still, then accelerates to twice the linear velocity when the point is at the top and then slow down back to 0 when you are back at the bottom point. However in a rotating system things can look quite different depending on the observer. From inside the wheel (local space) a point on the surface would not move at all, obviously, since it's part of the wheel and the particles the wheel is made of does not disintegrate itself. That's why local space velocity just makes not much sense for a rotating body.
So if you're looking for the world space linear velocity on a local point, using "GetPointVelocity" with a local point that is converted to worldspace is the way to go. Though if you want something else you have to be more specific what and why.
Thanks. I just wanted to know what that function does in case it provided some functionality that i might be going round about to implement. I am actually using getpointvelocity to get the velocity at the wheels of the car and apply friction to prevent it from sliding when still.