player animation completed
This commit is contained in:
parent
d0067b09c9
commit
9218b7b993
|
@ -3,30 +3,26 @@ using System;
|
|||
|
||||
public class PlayerIdleState : BaseState
|
||||
{
|
||||
private bool holdItem;
|
||||
public PlayerIdleState(StateMachine stateMachine, bool hi) : base(stateMachine)
|
||||
protected PlayerController player;
|
||||
|
||||
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine)
|
||||
{
|
||||
stateName = "Idle State";
|
||||
holdItem = hi;
|
||||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
//Debug.Log("WALK ENTER");
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
if (!holdItem)
|
||||
if (!machine.GetScript<PlayerController>().playLandedAnimation)
|
||||
{
|
||||
if (PlayerAnimations.Instance.playerIdleClip)
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerAnimations.Instance.playerCarryIdleClip)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
|
@ -34,6 +30,54 @@ public class PlayerIdleState : BaseState
|
|||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
else
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
|
||||
machine.GetScript<PlayerController>().playLandedAnimation = false;
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
else
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void update()
|
||||
|
|
|
@ -10,6 +10,60 @@ public class PlayerJumpState : BaseState
|
|||
public override void OnEnter()
|
||||
{
|
||||
//Debug.Log("jump");
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem && PlayerAnimations.Instance.playerJumpStartClip)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpStartClip);
|
||||
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpStartClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpStartClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpStartClip);
|
||||
|
||||
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpStartClip)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpStartClip)
|
||||
{
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpStartClip)
|
||||
{
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpStartClip)
|
||||
{
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (machine.GetScript<PlayerController>().holdItem && PlayerAnimations.Instance.playerJumpLoopClip)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerJumpLoopClip);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("missing playercontroller in jump state");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public override void update()
|
||||
{
|
||||
|
|
|
@ -9,7 +9,19 @@ public class PlayerLandState : BaseState
|
|||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
//Debug.Log("WALK ENTER");
|
||||
//Debug.Log("landed ENTER");
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpEndClip);
|
||||
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpEndClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpEndClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerJumpEndClip);
|
||||
}
|
||||
else
|
||||
machine.GetScript<PlayerController>().playLandedAnimation = false;
|
||||
}
|
||||
}
|
||||
public override void update()
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PlayerRunState : BaseState
|
|||
public override void OnEnter()
|
||||
{
|
||||
//Debug.Log("WALK ENTER");
|
||||
if (PlayerAnimations.Instance && PlayerAnimations.Instance.playerRunClip)
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
|
||||
|
|
|
@ -6,37 +6,37 @@ public class PlayerWalkState : BaseState
|
|||
{
|
||||
private float timer;
|
||||
private float delay = 0.5f;
|
||||
private bool holdItem;
|
||||
public PlayerWalkState(StateMachine stateMachine, bool hi) : base(stateMachine)
|
||||
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
|
||||
{
|
||||
stateName = "Walk State";
|
||||
holdItem = hi;
|
||||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
//Debug.Log("WALK ENTER");
|
||||
timer = delay;
|
||||
|
||||
machine.GetScript<PlayerController>().playLandedAnimation = false;
|
||||
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
if (!holdItem)
|
||||
{
|
||||
if (PlayerAnimations.Instance.playerWalkClip)
|
||||
if (!machine.GetScript<PlayerController>().holdItem)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerAnimations.Instance.playerCarryWalkClip)
|
||||
else if (machine.GetScript<PlayerController>().holdItem)
|
||||
{
|
||||
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Missing playercontroller in walk state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,13 @@ public class PickAndThrow : Script
|
|||
[Tooltip("Height of ray")]
|
||||
public float rayHeight = 0.1f;
|
||||
|
||||
[NonSerialized]
|
||||
private TweenThread camArmTween;
|
||||
[NonSerialized]
|
||||
private TweenThread foodTween;
|
||||
|
||||
public float tweenDuration = 0.3f;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
pc = GetScript<PlayerController>();
|
||||
|
@ -52,6 +59,10 @@ public class PickAndThrow : Script
|
|||
|
||||
timer = delayTimer;
|
||||
}
|
||||
|
||||
protected override void start()
|
||||
{
|
||||
}
|
||||
protected override void update()
|
||||
{
|
||||
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
|
||||
|
@ -96,6 +107,7 @@ public class PickAndThrow : Script
|
|||
pc.holdItem = false;
|
||||
inRange = false;
|
||||
throwItem = true;
|
||||
PlayThrowAnimation();
|
||||
timer = 0.0f;
|
||||
}
|
||||
|
||||
|
@ -131,6 +143,7 @@ public class PickAndThrow : Script
|
|||
{
|
||||
pc.holdItem = true;
|
||||
RetrieveItemComponets();
|
||||
PlayPickUpAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,5 +286,112 @@ public class PickAndThrow : Script
|
|||
return (pc.camArm.Pitch - tpc.pitchUpperClamp) / (tpc.pitchLowerClamp - tpc.pitchUpperClamp);
|
||||
}
|
||||
|
||||
private void PlayPickUpAnimation()
|
||||
{
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayThrowAnimation()
|
||||
{
|
||||
if (PlayerAnimations.Instance)
|
||||
{
|
||||
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerThrowClip);
|
||||
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
}
|
||||
});
|
||||
|
||||
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
||||
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
||||
{
|
||||
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
||||
{
|
||||
if (pc.isMoveKeyPress)
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
||||
else
|
||||
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,17 +7,17 @@ public class PlayerAnimations : Script
|
|||
{
|
||||
#region Raccoon
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerIdleClip; // done
|
||||
public AnimationClipAsset playerIdleClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerWalkClip; // done
|
||||
public AnimationClipAsset playerWalkClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerRunClip; // done
|
||||
public AnimationClipAsset playerRunClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerPickUpClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerCarryIdleClip; // done
|
||||
public AnimationClipAsset playerCarryIdleClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerCarryWalkClip; // done
|
||||
public AnimationClipAsset playerCarryWalkClip;
|
||||
[SerializeField]
|
||||
public AnimationClipAsset playerThrowClip;
|
||||
[SerializeField]
|
||||
|
@ -72,6 +72,37 @@ public class PlayerAnimations : Script
|
|||
|
||||
if (!silhoBagAnimator)
|
||||
Debug.LogError("Silho Player Animator is MISSING!");
|
||||
|
||||
if(!playerIdleClip)
|
||||
Debug.LogError("Idle clip is MISSING!");
|
||||
|
||||
if (!playerWalkClip)
|
||||
Debug.LogError("run clip is MISSING!");
|
||||
|
||||
if (!playerPickUpClip)
|
||||
Debug.LogError("Pickup clip is MISSING!");
|
||||
|
||||
if (!playerThrowClip)
|
||||
Debug.LogError("Throw clip is MISSING!");
|
||||
|
||||
if (!playerJumpStartClip)
|
||||
Debug.LogError("Jump start clip is MISSING!");
|
||||
|
||||
if (!playerJumpLoopClip)
|
||||
Debug.LogError("Jump loop clip is MISSING!");
|
||||
|
||||
if (!playerJumpEndClip)
|
||||
Debug.LogError("Jump end clip is MISSING!");
|
||||
|
||||
if (!playerCarryIdleClip)
|
||||
Debug.LogError("Carry idle clip is MISSING!");
|
||||
|
||||
if (!playerCarryWalkClip)
|
||||
Debug.LogError("Carry walk clip is MISSING!");
|
||||
|
||||
if (!playerRunClip)
|
||||
Debug.LogError("Run clip is MISSING!");
|
||||
|
||||
}
|
||||
|
||||
protected override void onDestroy()
|
||||
|
|
|
@ -83,6 +83,8 @@ public class PlayerController : Script
|
|||
public GameObject silhouetteBag;
|
||||
private Renderable silhouetteBagRend;
|
||||
|
||||
public bool playLandedAnimation { get; set; }
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
//default setup
|
||||
|
@ -108,8 +110,8 @@ public class PlayerController : Script
|
|||
|
||||
stateMachine = AddScript<StateMachine>();
|
||||
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
||||
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, holdItem));
|
||||
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, holdItem));
|
||||
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
|
||||
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine));
|
||||
dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine));
|
||||
dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine));
|
||||
dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine));
|
||||
|
@ -134,6 +136,8 @@ public class PlayerController : Script
|
|||
}
|
||||
|
||||
AudioHandler.audioClipHandlers["footsteps"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_footsteps");
|
||||
|
||||
playLandedAnimation = false;
|
||||
}
|
||||
|
||||
protected override void start()
|
||||
|
@ -189,6 +193,7 @@ public class PlayerController : Script
|
|||
MoveKey();
|
||||
Sprint();
|
||||
Jump();
|
||||
|
||||
//Debug.Log($"{currentState}");
|
||||
//Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}");
|
||||
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}");
|
||||
|
@ -305,12 +310,18 @@ public class PlayerController : Script
|
|||
|
||||
if (Input.GetKeyUp(Input.KeyCode.LeftShift))
|
||||
{
|
||||
if (isMoveKeyPress)
|
||||
if (isMoveKeyPress && isGrounded)
|
||||
{
|
||||
currentState = RaccoonStates.WALKING;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerWalkState)))
|
||||
stateMachine.SetState(typeof(PlayerWalkState));
|
||||
}
|
||||
else if(!isMoveKeyPress && isGrounded)
|
||||
{
|
||||
currentState = RaccoonStates.IDLE;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
|
||||
stateMachine.SetState(typeof(PlayerIdleState));
|
||||
}
|
||||
sprintIncreaseOnce = false;
|
||||
moveForce = oldForce;
|
||||
maxMoveVel = maxOldVel;
|
||||
|
@ -323,6 +334,7 @@ public class PlayerController : Script
|
|||
{
|
||||
if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null)
|
||||
{
|
||||
isGrounded = false;
|
||||
currentState = RaccoonStates.JUMP;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerJumpState)))
|
||||
stateMachine.SetState(typeof(PlayerJumpState));
|
||||
|
@ -386,6 +398,7 @@ public class PlayerController : Script
|
|||
if (currentState == RaccoonStates.FALLING)
|
||||
{
|
||||
currentState = RaccoonStates.LANDED;
|
||||
playLandedAnimation = true;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerLandState)))
|
||||
stateMachine.SetState(typeof(PlayerLandState));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue