Hi I want to know how to do the scripting for a slender type game more specifically I am trying to have my monster randomly walk around the map without passing through walls and once you come into a certain distance from it while looking at it the monster will begin to chase you and also i need a way that you can outrun it by getting a certain distance away at which time it will resume randomly walking around the map. I have a simple follow script here:
var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3;
var myTransform : Transform;
function Awake(){ myTransform = transform;
}
function Start(){ target = GameObject.FindWithTag(“Player”).transform;
}
function Update () { myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
I tested it and it works but I want it to also walk around the map instead of being in a fixed position then once it sees me it chases me. any help is appreciated. Thanks in advance.