Question by
Dog-Gamer · May 14, 2016 at 01:18 AM ·
javascriptprogramming
Enemy keeps floating throw roof?
Every time the player follows the player it just starts going tword them then floats up. I have locked the X,Y,Z rotation and turned on the box collider any help? Coding used for them to follow player:
var target : Transform; //the enemy's target
var moveSpeed = 3; //move speed
var rotationSpeed = 3; //speed of turning
var myTransform : Transform; //current transform data of this enemy
function Awake()
{
myTransform = transform; //cache transform data for easy access/preformance
}
function Start()
{
target = GameObject.FindWithTag("Player").transform; //target the player
}
function Update () {
//rotate to look at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
Comment
Your answer
Follow this Question
Related Questions
enemy looking randomly? 0 Answers
Spawn a dot for every number typed? 0 Answers
Have FPS Controller Crouch to hide player? 1 Answer
What is causing the object to fly upwards? 1 Answer
Why wont this work? 0 Answers