- Home /
How can I get my enemy to rotate to look at my character in my 2D game??
I have some code for making the enemy look at the character but it rotates it face to look at me
This is what it looks like in game and scene view. The characters have rotated their faces to look at me whereas i would only like their edge to look at me. This is my code:
Vector3 lookAtGoal = new Vector3(player.position.x, this.transform.position.y, player.position.z);
this.transform.LookAt(lookAtGoal);
Answer by Charlie010903 · Apr 24, 2020 at 01:02 PM
This is how I would like it to look
with just an edge looking at me
Answer by Luis_Gan · Apr 28, 2020 at 04:50 AM
Try this:
public Transform target;
void Update()
{
transform.right = target.position - transform.position;
}
@$$anonymous$$ that kind of works but they flip over sometimes which i don't want
Your answer
Follow this Question
Related Questions
LookAt Limit Up and Down rotation only 2 Answers
Making a specific axis look at an object 2 Answers
LookAt something while rotating on z? 1 Answer
LookAt on one axis 2 Answers
Flip 2D object on X axis because of a moving target. 1 Answer