void Update() { #if UNITY_EDITOR CurrentState = sm.currentState; #endif #region Tiempo de recuperación del estado de Derribo (Smashed) if (_remainingSmashTime > 0) { _remainingSmashTime -= Time.deltaTime; } else if (_Smashed && _remainingSmashTime <= 0) { _remainingSmashTime = 0; anims.SetBool("Smashed", false); } #endregion sight.Update(); if (LookTowardsPlayer) { transform.forward = Vector3.Lerp(transform.forward, sight.dirToTarget, _rotationLerpSpeed * Time.deltaTime); } sm.Update(); }
// Update is called once per frame void Update() { FSM.Update(); if (Input.GetKey(KeyCode.Q)) { FSM.SetState(0); } if (Input.GetKey(KeyCode.W)) { FSM.SetState(1); } if (Input.GetKey(KeyCode.E)) { FSM.SetState(2); } }
// Update is called once per frame public override void Update() { base.Update(); FSM.Update(); //Chequea que no haya ocurrido ningun cambio en la FSM. //-------------Line of Sight---------------------------------------------------------------------------- CheckForEnemies(); //---------------------State triggers------------------------------------------------------------------- if (CurrentTarget != null) { float Dist = Vector3.Distance(transform.position, CurrentTarget.transform.position); //Si esta dentro de mi rango, lo Ataco. if (Dist <= BSO_AttackRange) { FSM.SetState(2); //Attack Current Target } //Si hay al menos un objetivo visible y esta mas lejos que mi rango de ataque. if (Dist > BSO_AttackRange && CurrentTarget != null) { FSM.SetState(1); //Pursuit Target. } } }
// Update is called once per frame void Update() { #if UNITY_EDITOR current = _sm.currentState; #endif if (Disarmed) { if (_currentDisarmedTime > 0) { _currentDisarmedTime -= Time.deltaTime; } else if (_currentDisarmedTime <= 0) { Disarmed = false; _sm.Feed(ShieldEnemyStates.think); } } //Condición de muerte, Update de Sight, FSM y Rotación. if (IsAlive) { sight.Update(); if (LookTowardsPlayer && _targetDetected) { transform.forward = Vector3.Lerp(transform.forward, sight.dirToTarget, _rotationLerpSpeed * Time.deltaTime); } _sm.Update(); } else if (_sm.currentState != ShieldEnemyStates.dead) { _sm.Feed(ShieldEnemyStates.dead); } }