- Home /
Question by
oinkoinkflapflap · May 19, 2014 at 03:11 PM ·
transformtime.deltatimewaypointmovetowardsinstantly
MoveTowards happening instantly
I have made a basic waypoint script, using MoveTowards, but it seems to take no notice of the speed i set and does it instantly, even if 'moveSpeed' is set to 0 or 0.0000001! It's the same as when i've used MoveTowards in the past, I don't understand why it's doing it instantly, below is the section of script, it's under function Update:
if(beginVortex){
transform.position = Vector3.MoveTowards(waypoints[pointNumber].transform.position, transform.position, moveSpeed*Time.deltaTime);
var distPoint : float = Vector3.Distance(waypoints[pointNumber].position, transform.position);
if(distPoint <= 1){
pointNumber += 1;
}
}
Thanks in advance!
Comment
Best Answer
Answer by robertbu · May 19, 2014 at 03:20 PM
Assuming your are trying to move this object towards a waypoint, and assuming the above code is called every frame (while beginVortex is true), then you need to change line 2 to:
transform.position = Vector3.MoveTowards(transform.position, waypoints[pointNumber].transform.position, moveSpeed*Time.deltaTime);
ahh I've put them the wrong way around! why didn't I think of that! Thank you for your rapid, and correct response!
Your answer
![](https://koobas.hobune.stream/wayback/20220613145411im_/https://answers.unity.com/themes/thub/images/avi.jpg)