Would somebody either explain how I'd go about it or tell me how to have an object follow another object and stop once within a certain distance? Imagine a pet following a character, something basic like that.
var minDist;
var speed;
function Update(){
chase();
}
function chase(){
//Find which way player is facing, make the "pet" point to it and move at speed*1
checkDistance();
}
function checkDistance(){
//var distance = distance between player and pet;
if(distance <= minDist){
speed = 0;
}
else{
speed = //Whatever your speed is...
}
}
Something like this should work =).