Hi I am using a basic bit of code to make an enemy I have within a game to follow after the player, however it doesn't move within the level it moves over it not colliding with anything.
here is the code I am using:
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist : float = 0.5;
function Start ()
{
}
function Update ()
{
//transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist)
{
//transform.position += transform.forward*MoveSpeed*Time.deltaTime;
transform.position += (Player.transform.position - transform.position).normalized* MoveSpeed* Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
{
}
}
}
if anyone knows an easy way to make it move within the level that would be great. Also sorry if the code is bad or the question is bad I am very new to this.
↧