So I’m literally just trying to have a character patrol through several checkpoints over and over again, but whenever I run the script, the player is moving super fast. No matter what I make the speed, it still goes really fast, so I don’t know what’s wrong. I’ve only been using unity for a few weeks so the answer’s probably stupid and obvious, but still.
var theEnemy : Transform;
var checkpoints : Transform[];
var currentCheckpoint = 0;
var speed = 0.01;
var currentDistance = Vector3.Distance(checkpoints[currentCheckpoint].position, theEnemy.position);
function Update(){
if(currentCheckpoint < checkpoints.length){
theEnemy.position = Vector3.MoveTowards(checkpoints[currentCheckpoint].position, theEnemy.position, speed * Time.deltaTime);
if(currentDistance<1){
currentCheckpoint++;
}
}
else{
currentCheckpoint = 0;
}
}