Exemple #1
0
 // Update is called once per frame
 protected virtual void Update()
 {
     _directionAxis = Vector2.zero;
     if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
     {
         _directionAxis.x = Vector2.right.x;
     }
     else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
     {
         _directionAxis.x = Vector2.left.x;
     }
     else if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
     {
         _directionAxis.y = Vector2.up.y;
     }
     else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
     {
         _directionAxis.y = Vector2.down.y;
     }
     else
     {
         _directionAxis.x = Input.GetAxisRaw("Horizontal");
         _directionAxis.y = Input.GetAxisRaw("Vertical");
     }
     if (Mathf.Abs(_directionAxis.x) >= MoveAxisDeadZone ||
         Mathf.Abs(_directionAxis.y) >= MoveAxisDeadZone)
     {
         CharacterAnimParams.TrySetAxisHorizontal(ControllerComponent.AnimatorComponent, _directionAxis.x);
         CharacterAnimParams.TrySetAxisVertical(ControllerComponent.AnimatorComponent, _directionAxis.y);
     }
 }
        /// <summary>
        /// Add events to FSM states and set initial state
        /// </summary>
        private void InitStates()
        {
            FSMFlyable = new BTFiniteStateMachine <FStatesFlyable>(StartInAir ? FStatesFlyable.Flying : FStatesFlyable.NotFlying);
            FSMFlyable.OnStarted_AddListener(FStatesFlyable.TakingOff, TakingOff_Enter);
            FSMFlyable.SetUpdateAction(FStatesFlyable.TakingOff, TakingOff_Update);
            FSMFlyable.OnStopped_AddListener(FStatesFlyable.TakingOff, TakingOff_Exit);

            FSMFlyable.OnStarted_AddListener(FStatesFlyable.Landing, Landing_Enter);
            FSMFlyable.SetUpdateAction(FStatesFlyable.Landing, Landing_Update);

            FSMFlyable.OnStarted_AddListener(FStatesFlyable.NotFlying, NotFlying_Enter);
            FSMFlyable.OnStopped_AddListener(FStatesFlyable.NotFlying, NotFlying_Exit);

            FSMFlyable.OnStarted_AddListener(FStatesFlyable.Flying, Flying_Enter);

            FSMFlyable.OnStateChanged_AddListener(OnFlyableStateChanged_Listener);
            CharacterAnimParams.TrySetFStateFlyable(AnimatorComponent, (int)FSMFlyable.CurrentState);
        }
Exemple #3
0
 public void AnimateLocomotion()
 {
     CharacterAnimParams.TrySetSpeed(AnimatorComponent, CurrentSpeed);
 }
 protected override void Update()
 {
     base.Update();
     CharacterAnimParams.TrySetSpeed(AnimatorComponent, m_currentBotMovementComponent.CurrentSpeed);
 }
 void NotFlying_Exit()
 {
     ToggleFlight(false);
     CharacterAnimParams.TrySetIsGrounded(AnimatorComponent, false);
 }
 protected virtual void Update()
 {
     CharacterAnimParams.TrySetSpeed(BotComponent.AnimatorComponent, CurrentSpeed);
 }
Exemple #7
0
 protected virtual void UpdateAnimationParams()
 {
     CharacterAnimParams.TrySetSpeedPercent(AnimatorComponent, Mathf.Abs(CurrentSpeedPercentHorizontal));
 }
 protected override void Update()
 {
     base.Update();
     CharacterAnimParams.TrySetSpeed(AnimatorComponent, BotFSMLocomotionComponent.CurrentSpeed);
 }
 private void OnFlyableStateChanged_Listener(BotFlyable.FStatesFlyable state)
 {
     CharacterAnimParams.TrySetFStateFlyable(AnimatorComponent, (int)state);
 }