Hey guys, i was just wondering if there were any good character follow scripts. like pikmen. like you run into them and then they follow you. Would be great if someone whipped that together or at least began the code.
Thanks.
A good place to search for premade scripts is the Unity wiki, but the basic implementation of “follow player” is incredibly trivial and it’s unlikely you’d find anything significantly better suited to your program than
var player : Transform; // insert player transform here
var speed :float;
var followDistance : float;
function Update() {
transform.LookAt( player );
var d = transform.position - player.position;
if ( d.magnitude > followDistance ) {
transform.position += d.normalized * speed;
}
}