- Home /
Do something when lerp reached target.
Hello.
I am using Vector3.Lerp to get to move a object to another one, everything goes well, but how would I do another task when the object reached the other one(or when it is close enough). How would I track the progress of that lerp?
Thank you!
If the problem is solved, make sure to close the question in order to remove it from the unanswered category.
whats the solution for that??Can you please share it?? Thank you
Answer by Immanuel-Scholz · Nov 14, 2014 at 08:46 AM
Your solution is probably to test the new vector whether it now is equal with the vector before.
Vector3 oldPos = transform.position;
transform.position = Vector3.Lerp(oldPos, target, dt);
if (oldPos == transform.position)
{
// we arrived. Do some stuff here. Be sure to disable the Lerp or this
// triggers again.
}
Yeah, figured out myself.
Its always nice to give the answer if you figure it out. Others may have similar problems. Also, you can answer your own question without problems and mark your own answer as valid. This helps people who scan for "unanswered questions". ;)
Your answer
Follow this Question
Related Questions
Vector3.Lerp works outside of Update() 3 Answers
Not Sure How to Get Around this Problem 1 Answer
Vector3.lerp doesn't work 1 Answer
Lerp not working 1 Answer
Lerp isn't completing itself 3 Answers