diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index 5a6d52fb..8219b365 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -7591,7 +7591,7 @@ IsActive: true Renderable Component: Mesh: 149697411 - Material: 126974645 + Material: 128805346 IsActive: true RigidBody Component: Type: Dynamic @@ -7621,6 +7621,10 @@ Position Offset: {x: 0, y: 0.300000012, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true + Animator Component: + Rig: 77816045 + AnimationController: 0 + IsActive: true Scripts: - Type: PlayerController Enabled: true @@ -7639,6 +7643,10 @@ heavyMultiper: 0.5 silhouettePlayer: 462 silhouetteBag: 465 + idleClip: 227450439 + walkClip: 229125027 + runClip: 228149757 + pickUpClip: 0 - Type: PickAndThrow Enabled: true throwForce: [8, 10, 8] diff --git a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerIdleState.cs b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerIdleState.cs index 144233a3..8c5044c0 100644 --- a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerIdleState.cs +++ b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerIdleState.cs @@ -3,13 +3,18 @@ using System; public class PlayerIdleState : BaseState { - public PlayerIdleState(StateMachine stateMachine) : base(stateMachine) + private AnimationClipAsset idleClip; + private Animator animator; + public PlayerIdleState(StateMachine stateMachine, Animator ani , AnimationClipAsset clip) : base(stateMachine) { stateName = "Idle State"; + idleClip = clip; + animator = ani; } public override void OnEnter() { //Debug.Log("WALK ENTER"); + animator.Play(idleClip); } public override void update() { diff --git a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerRunState.cs b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerRunState.cs index 314f8950..0ff4be17 100644 --- a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerRunState.cs +++ b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerRunState.cs @@ -6,13 +6,19 @@ public class PlayerRunState : BaseState private float timer; private float delay = 0.25f; - public PlayerRunState(StateMachine stateMachine) : base(stateMachine) + private AnimationClipAsset runClip; + private Animator animator; + + public PlayerRunState(StateMachine stateMachine, Animator ani, AnimationClipAsset clip) : base(stateMachine) { stateName = "Run State"; + animator = ani; + runClip = clip; } public override void OnEnter() { //Debug.Log("WALK ENTER"); + animator.Play(runClip); } public override void update() { diff --git a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerWalkState.cs b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerWalkState.cs index 1c0ef13a..5609825d 100644 --- a/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerWalkState.cs +++ b/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerWalkState.cs @@ -5,14 +5,20 @@ public class PlayerWalkState : BaseState { private float timer; private float delay = 0.5f; - public PlayerWalkState(StateMachine stateMachine) : base(stateMachine) + + private AnimationClipAsset walkClip; + private Animator animator; + public PlayerWalkState(StateMachine stateMachine, Animator ani, AnimationClipAsset clip) : base(stateMachine) { stateName = "Walk State"; + animator = ani; + walkClip = clip; } public override void OnEnter() { //Debug.Log("WALK ENTER"); timer = delay; + animator.Play(walkClip); } public override void update() { diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index 284b4cc1..dd59975f 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -82,6 +82,21 @@ public class PlayerController : Script public GameObject silhouetteBag; private Renderable silhouetteBagRend; + #region Serialized Fields + [SerializeField] + private AnimationClipAsset idleClip; + [SerializeField] + private AnimationClipAsset walkClip; + [SerializeField] + private AnimationClipAsset runClip; + [SerializeField] + private AnimationClipAsset pickUpClip; + #endregion + + #region Components + public Animator animator { get; private set; } + #endregion + protected override void awake() { //default setup @@ -98,18 +113,22 @@ public class PlayerController : Script //rigidbody check rb = GetComponent(); if (!rb) - Debug.LogError("RigidBody is NULL!"); + Debug.LogError("RigidBody is MISSING!"); //Transform check tranform = GetComponent(); if(!tranform) - Debug.LogError("tranform is NULL!"); + Debug.LogError("tranform is MISSING!"); + + animator = GetComponent(); + if (!animator) + Debug.LogError("Animator is MISSING!"); stateMachine = AddScript(); Dictionary dictionary = new Dictionary(); - dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine)); - dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine)); - dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine)); + dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, animator , idleClip)); + dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, animator , walkClip)); + dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine, animator, runClip)); dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine)); dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine)); dictionary.Add(typeof(PlayerLandState), new PlayerLandState(stateMachine));