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