// Update is called once per frame
 void Update()
 {
     canPatrol = allowerMovement.Raycasting();
     isChasing = allowerChasing.Raycasting();
     // The agent chases the player
     if (isChasing && !allowerMovement.GetPlayerHidingStatus())
     {
         patrolingEnemy.AjustModelOrientation(transform.position.x, allowerMovement.GetPlayerPos().x);
         transform.position = playerPersecutor.Chasing(transform.position, allowerMovement.GetPlayerPos());
         HidingPlaceCtrl.hidingPlaceCtrl.DisableHidingPlaces();
         canPatrol = false;
     }
     // the agent patrols
     if (canPatrol)
     {
         patrolingEnemy.UpdatePatrollingOrientation(transform.position.x);
         transform.position = patrolingEnemy.Patrolling(transform.position);
         HidingPlaceCtrl.hidingPlaceCtrl.EnableHidingPlaces();
     }
     // agent comes back to its original position if it leaves the patrolling vision ratio
     if (!patrolliArea.IsAgentOnThePatrollingArea() && !canPatrol && !isChasing)
     {
         patrolingEnemy.UpdatePatrollingOrientation(transform.position.x);
         transform.position = patrolingEnemy.Patrolling(transform.position);
         HidingPlaceCtrl.hidingPlaceCtrl.EnableHidingPlaces();
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     canPatrol = allowerMovement.Raycasting();
     if (canPatrol)
     {
         print("y");
         transform.position = patrolingEnemy.Patrolling(transform.position);
         animator.SetInteger("state", 1);
     }
     else
     {
         animator.SetInteger("state", 0);
     }
 }