JojikYT

SprintJumpState

Dec 18th, 2021 (edited)
2,569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using UnityEngine;
  2. public class SprintJumpState:State
  3. {
  4.     float timePassed;
  5.     float jumpTime;
  6.  
  7.     public SprintJumpState(Character _character, StateMachine _stateMachine) : base(_character, _stateMachine)
  8.     {
  9.         character = _character;
  10.         stateMachine = _stateMachine;
  11.     }
  12.  
  13.     public override void Enter()
  14.     {
  15.         base.Enter();
  16.         character.animator.applyRootMotion = true;
  17.         timePassed = 0f;
  18.         character.animator.SetTrigger("sprintJump");
  19.  
  20.         jumpTime = 1f;
  21.     }
  22.  
  23.     public override void Exit()
  24.     {
  25.         base.Exit();
  26.         character.animator.applyRootMotion = false;
  27.     }
  28.  
  29.     public override void LogicUpdate()
  30.     {
  31.        
  32.         base.LogicUpdate();
  33.         if (timePassed> jumpTime)
  34.         {
  35.             character.animator.SetTrigger("move");
  36.             stateMachine.ChangeState(character.sprinting);
  37.         }
  38.         timePassed += Time.deltaTime;
  39.     }
  40.  
  41.  
  42.  
  43. }
  44.  
  45.  
Add Comment
Please, Sign In to add comment