Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

JS Enemy Angle Rotation Follow

$
0
0
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;

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>