Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerRunState : PlayerBaseState
- {
- public PlayerRunState(PlayerStateMachine currentContext, PlayerStateFactory playerStateFactory)
- : base(currentContext, playerStateFactory) { }
- public override void EnterState() {
- }
- public override void UpdateState() {
- CheckSwitchStates();
- Ctx.PlayerMovementX = Ctx.InputMoveX * Ctx.SprintSpeed;
- Ctx.PlayerMovementZ = Ctx.InputMoveY * Ctx.SprintSpeed;
- //animation
- Ctx.AnimCon.SetFloat(Ctx.HorizontalAnim, Ctx.InputMoveX);
- Ctx.AnimCon.SetFloat(Ctx.VerticalAnim, Ctx.InputMoveY);
- }
- public override void ExitState() { }
- public override void InitializeSubState() { }
- public override void CheckSwitchStates()
- {
- if (Ctx.InputMoveX != 0 || Ctx.InputMoveY != 0)
- {
- if (!Ctx.InputRun)
- {
- SwitchState(Factory.Walk());
- }
- }
- else
- {
- SwitchState(Factory.Idle());
- }
- }
- }
Add Comment
Please, Sign In to add comment