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

Enemy follows the only player in rotation

$
0
0
2d game. My enemy is following me right and left, but when I jump, the enemy turns to me. I would like to jump when the enemy stands still while they are not looking up. How can I fix? Script that I'm using. using UnityEngine; using System.Collections; public class EnemyAI : MonoBehaviour { public Transform target;//set target from inspector instead of looking in Update public float speed = 3f; void Start () { } void Update(){ //rotate to look at the player transform.LookAt(target.transform.position); transform.Rotate(new Vector3(0,-90,0),Space.Self);//correcting the original rotation } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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