- Home /
Strange/Buggy code behavier
Hallo guys,
why is this code setting my rigidbody velocity to 0?
rigidbody.velocity = Vector3.Lerp(rigidbody.velocity, rigidbody.velocity, 0);
It makes no sence to me :(
Vector3.Lerp(rigidbody.velocity, rigidbody.velocity, 0);
is returning the right velocity, but if I set rigidbody.velocity with this line, the velocity is {0, 0, 0}
I am using C#
RaverTiny
Comment
rigidbody.velocity = Vector3.Lerp(rigidbody.velocity, rigidbody.velocity, 0);
It makes no sense. You're telling Unity to interpolate between two of the same values which returns rigidbody.velocity. What are you trying to achieve?
Could you make a small test and put 2x Debug.Log there:
Debug.Log("1: " + rigidbody.velocity);
rigidbody.velocity = Vector3.Lerp(rigidbody.velocity, rigidbody.velocity, 0);
Debug.Log("2: " + rigidbody.velocity);
and see what the output is?
Best Answer
Answer by TinySoftt · Sep 09, 2013 at 11:40 AM
Seems like I just had to restart Unity... strange.
Your answer
Follow this Question
Related Questions
C# Bullets do not fly, just fall... 3 Answers
Unity relative velocity limiting 0 Answers
RigidBody clips into corners 3 Answers
GameObject disappears when velocity is set to (near) zero. 1 Answer