// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { target = GameObject.Find("Player"); NPC = animator.gameObject; agent = NPC.GetComponent <NavMeshAgent>(); EnemyCharacter = NPC.GetComponent <EnemyThirdPersonCharacter>(); agent.updateRotation = true; agent.updatePosition = true; agent.isStopped = false; }
// Start is called before the first frame update void Start() { agent = GetComponent <NavMeshAgent>(); character = GetComponent <EnemyThirdPersonCharacter>(); //target_position = transform.position;//makes him stay in place at the start //Debug.Log(target_position + "start" + transform.position); agent.updateRotation = true; agent.updatePosition = true; agent.isStopped = false; }
//public EnemyAI private void Start() { // get the components on the object we need ( should not be null due to require component so no need to check ) agent = GetComponentInChildren <UnityEngine.AI.NavMeshAgent>(); character = GetComponent <EnemyThirdPersonCharacter>(); agent.updateRotation = false; agent.updatePosition = true; target_position = transform.position;//makes him stay in place at the start Debug.Log(target_position + "start" + transform.position); }