Hi all. I'm making a 2d game, and trying to get an enemy to look at the player constantly. The catch, is that my 2d game is not a platformer, but an overhead shooter where everything lies on the x,y plane. I have a script set up right now which effectivly follows and looks at the player, but when it rotates, it does it on the wrong axis. I've tried everything! Thanks for you help in advance,
-Alec
Code-
public var moveSpeed = 3; //move speed
public var rotationSpeed = 3; //speed of turning
target = GameObject.FindWithTag("player").transform; //target the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
↧