Hi everyone!
I’ve a problem and I haven’t found any solution.
I’ve this coroutine:
public IEnumerator moveObjectBySquat()
{
Vector3 source = transform.position;
Vector3 target = new Vector3 (source.x, source.y - 0.5f, 0f);
float startTime = Time.time;
while(Time.time < startTime + OVER_TIME)
{
transform.position = Vector3.Lerp(source, target, (Time.time - startTime)/OVER_TIME);
yield return null;
}
transform.position=target;
}
And I call the coroutine from the Update method:
void Update(){
if(booleanVar){
StartCoroutine(moveObjectToSourcePosition ());
}
}
It works correctly, but when coroutine is finished the gameObject restarts to their original position automatically…
Any idea?