- Home /
Hello, Need some help with Enemy facing the player on z axis !!
Vector3 difference = player.transform.position - transform.position;
float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotationZ*2);
This is the code im using but the problem is the 2d sprite rotates around it's center instead of its face. I've picked the code from another source so i've no idea what's going on. please can some one point me in the right direction. Thanks in advance.:)
Comment
Your answer
Follow this Question
Related Questions
!Urgent! How to get a sprite to look at another object? 1 Answer
LookAt Translation Not Sticking 1 Answer
Lock rotation axis? 4 Answers
Joint Transform Rotation in Unity? 0 Answers
transform.LookAt issue 1 Answer