- Home /
How to prevent MoveToward from reducing the speed?
My plane begin reducing the speed before the object
var target = GameObject.Find("target");
var speed : float;
speed = 0.5*Time.deltaTime;
plane.position = Vector3.MoveTowards(plane.transform.position, target.transform.position, speed);
$$anonymous$$eep 'speed' the same value to prevent reducing speed. You are subtracting from it each frame. Also note that you should be scaling speed by deltaTime. Assu$$anonymous$$g the above code is in Update(), you should be caching the result of the GameObject.Find().
robertbu, even if i did speed += 0.5*Time.deltaTime; it is still recuing the speed before the object
It appears you've edited the code in the question. I see no reason that this updated code should have a slow down. Is it possible that there is either another script or physics (a collision) that is impacting the movement? Run a quick test with this script in a new scene.
Note your use of plane.position and plane.transform.position in the final line. Not the reason for the slowdown.