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

How to fix enemy's rotation (2D)

$
0
0
So I have a script assigned to my enemy for it to follow my player and the problem is it keeps rotating on the y axis, How can i fix this, Here's the script: public Transform Player; int MoveSpeed = 4; float MaxDist = 10f; float MinDist = 5f; void Update () { transform.LookAt(Player); if (Vector2.Distance(transform.position, Player.position) >= MinDist) { transform.position += transform.forward * MoveSpeed * Time.deltaTime; if (Vector2.Distance(transform.position, Player.position) <= MaxDist) { //Here Call a function for shooting } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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