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
}
}
↧