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

How to rotate the enemy in 2D top down

$
0
0
I use that script to rotate enemy but he stop at 90 and -90 deegres. Any solution Start rotation0/-90/90 public class LookAtSth : MonoBehaviour { public Transform target; public float rotationSpeed; private Quaternion lookRotation; private Vector3 direction; public void Start() { target = GameObject.FindGameObjectWithTag("Player").transform; } void Update() { direction = (target.position - transform.position).normalized; lookRotation = Quaternion.LookRotation(direction); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed); transform.eulerAngles = new Vector3(transform.eulerAngles.x, -90, 90); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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