Hello. I have this code to move an enemy object towards the player, as so:
var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3;
var myTransform : Transform;
function Awake()
{
myTransform = transform;
target = GameObject.FindWithTag("Player").transform;
}
function Update ()
{
var distance = Vector3.Distance( target.position, myTransform.position);
if (distance < 35)
{
SendMessage("SetSpeedOilBlob" , 2.0);
var lookDir = target.position - myTransform.position;
lookDir.y = 0;
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(lookDir), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
Debug.Log("" + distance);
}
The enemy itself is moving fine and following me which is what i want it to do, however when i climb a hill that has been created with Unity’s terrain editor (I went to Terrain and created a hill with the terrain editor, this is the hill i am using) the enemy does not collide with the hill and rather just passes through it. The enemy has a character controller on it, i thought this would be sufficient for collision detection? The goal here would be for it to just collide with the hill and stop moving while still having it try to follow me. How would i go about this?
*The “SendMessage” is for animations on the object