Raccoon animation and scene changes #415

Merged
glencelow merged 16 commits from PlayerController into main 2023-03-10 17:28:16 +08:00
10 changed files with 158 additions and 62 deletions
Showing only changes of commit 9b9cf1a1bb - Show all commits

View File

@ -2419,7 +2419,7 @@
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 0, z: 0} Translate: {x: 0, y: 0, z: 0}
Rotate: {x: -1.48352981, y: 0, z: 0} Rotate: {x: -7.50001717, y: 1.39999998, z: -3.50001717}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
Renderable Component: Renderable Component:
@ -7643,10 +7643,6 @@
heavyMultiper: 0.5 heavyMultiper: 0.5
silhouettePlayer: 462 silhouettePlayer: 462
silhouetteBag: 465 silhouetteBag: 465
idleClip: 227450439
walkClip: 229125027
runClip: 228149757
pickUpClip: 0
- Type: PickAndThrow - Type: PickAndThrow
Enabled: true Enabled: true
throwForce: [8, 10, 8] throwForce: [8, 10, 8]
@ -7660,6 +7656,20 @@
Enabled: true Enabled: true
currentStateName: Idle State currentStateName: Idle State
currentAnimName: "" currentAnimName: ""
- Type: PlayerAnimations
Enabled: true
playerIdleClip: 227450439
playerWalkClip: 229125027
playerRunClip: 228149757
playerPickUpClip: 219605278
playerCarryIdleClip: 231128260
playerCarryWalkClip: 227671720
playerThrowClip: 223399345
playerJumpStartClip: 223009573
playerJumpLoopClip: 230974023
playerJumpEndClip: 228134756
silhouettePlayer: 51000
silhouetteBag: 51000
- EID: 65733 - EID: 65733
Name: HoldingPoint Name: HoldingPoint
IsActive: true IsActive: true
@ -7722,7 +7732,11 @@
IsActive: true IsActive: true
Renderable Component: Renderable Component:
Mesh: 144838771 Mesh: 144838771
Material: 123745521 Material: 117923942
IsActive: true
Animator Component:
Rig: 77816045
AnimationController: 0
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 462 - EID: 462

View File

@ -3,18 +3,28 @@ using System;
public class PlayerIdleState : BaseState public class PlayerIdleState : BaseState
{ {
private AnimationClipAsset idleClip; private bool holdItem;
private Animator animator; public PlayerIdleState(StateMachine stateMachine, bool hi) : base(stateMachine)
public PlayerIdleState(StateMachine stateMachine, Animator ani , AnimationClipAsset clip) : base(stateMachine)
{ {
stateName = "Idle State"; stateName = "Idle State";
idleClip = clip; holdItem = hi;
animator = ani;
} }
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //Debug.Log("WALK ENTER");
animator.Play(idleClip); if (PlayerAnimations.Instance)
{
if (!holdItem)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
}
else
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
}
} }
public override void update() public override void update()
{ {

View File

@ -6,19 +6,18 @@ public class PlayerRunState : BaseState
private float timer; private float timer;
private float delay = 0.25f; private float delay = 0.25f;
private AnimationClipAsset runClip; public PlayerRunState(StateMachine stateMachine) : base(stateMachine)
private Animator animator;
public PlayerRunState(StateMachine stateMachine, Animator ani, AnimationClipAsset clip) : base(stateMachine)
{ {
stateName = "Run State"; stateName = "Run State";
animator = ani;
runClip = clip;
} }
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //Debug.Log("WALK ENTER");
animator.Play(runClip); if (PlayerAnimations.Instance)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
}
} }
public override void update() public override void update()
{ {

View File

@ -5,20 +5,33 @@ public class PlayerWalkState : BaseState
{ {
private float timer; private float timer;
private float delay = 0.5f; private float delay = 0.5f;
private bool holdItem;
private AnimationClipAsset walkClip; public PlayerWalkState(StateMachine stateMachine, bool hi) : base(stateMachine)
private Animator animator;
public PlayerWalkState(StateMachine stateMachine, Animator ani, AnimationClipAsset clip) : base(stateMachine)
{ {
stateName = "Walk State"; stateName = "Walk State";
animator = ani; holdItem = hi;
walkClip = clip;
} }
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //Debug.Log("WALK ENTER");
timer = delay; timer = delay;
animator.Play(walkClip); if (PlayerAnimations.Instance)
{
if (!holdItem)
{
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
}
else
{
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
}
}
} }
public override void update() public override void update()
{ {

View File

@ -0,0 +1,75 @@
using SHADE;
using System;
using System.Collections.Generic;
public class PlayerAnimations : Script
{
#region Raccoon
[SerializeField]
public AnimationClipAsset playerIdleClip; // done
[SerializeField]
public AnimationClipAsset playerWalkClip; // done
[SerializeField]
public AnimationClipAsset playerRunClip; // done
[SerializeField]
public AnimationClipAsset playerPickUpClip;
[SerializeField]
public AnimationClipAsset playerCarryIdleClip; // done
[SerializeField]
public AnimationClipAsset playerCarryWalkClip; // done
[SerializeField]
public AnimationClipAsset playerThrowClip;
[SerializeField]
public AnimationClipAsset playerJumpStartClip;
[SerializeField]
public AnimationClipAsset playerJumpLoopClip;
[SerializeField]
public AnimationClipAsset playerJumpEndClip;
#endregion
#region Animator
public Animator playerAnimator { get; private set; }
public Animator BagAnimator { get; private set; }
public Animator silhoPlayerAnimator { get; private set; }
public Animator silhoBagAnimator { get; private set; }
#endregion
#region silhouette
public GameObject silhouettePlayer;
public GameObject silhouetteBag;
#endregion
public static PlayerAnimations Instance { get; private set; }
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<PlayerAnimations>();
else
Instance = this;
playerAnimator = GetComponent<Animator>();
if (!playerAnimator)
Debug.LogError("Player Animator is MISSING!");
BagAnimator = GetComponentInChildren<Animator>();
if (!BagAnimator)
Debug.LogError("Bag Animator is MISSING!");
silhoPlayerAnimator = silhouettePlayer.GetComponent<Animator>();
if (!silhoPlayerAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
silhoBagAnimator = silhouetteBag.GetComponent<Animator>();
if (!silhoBagAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
}

View File

@ -0,0 +1,3 @@
Name: SC_PlayerAnimations
ID: 159045981
Type: 9

View File

@ -32,7 +32,7 @@ public class PlayerController : Script
private float delayTimer = 0.0f; private float delayTimer = 0.0f;
[Tooltip("The current state fo the raccoon")] [Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDLE; public RaccoonStates currentState;
//Movement variables============================================================ //Movement variables============================================================
[Tooltip("Max vel for walking")] [Tooltip("Max vel for walking")]
@ -82,21 +82,6 @@ public class PlayerController : Script
public GameObject silhouetteBag; public GameObject silhouetteBag;
private Renderable silhouetteBagRend; 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() protected override void awake()
{ {
//default setup //default setup
@ -120,15 +105,11 @@ public class PlayerController : Script
if(!tranform) if(!tranform)
Debug.LogError("tranform is MISSING!"); Debug.LogError("tranform is MISSING!");
animator = GetComponent<Animator>();
if (!animator)
Debug.LogError("Animator is MISSING!");
stateMachine = AddScript<StateMachine>(); stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>(); Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, animator , idleClip)); dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, animator , walkClip)); dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine, animator, runClip)); dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine));
dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine)); dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine));
dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine)); dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine));
dictionary.Add(typeof(PlayerLandState), new PlayerLandState(stateMachine)); dictionary.Add(typeof(PlayerLandState), new PlayerLandState(stateMachine));
@ -152,6 +133,12 @@ public class PlayerController : Script
} }
} }
protected override void start()
{
currentState = RaccoonStates.IDLE;
stateMachine.SetState(typeof(PlayerIdleState));
}
protected override void lateUpdate() protected override void lateUpdate()
{ {
} }

View File

@ -50,6 +50,7 @@ public class PauseMenu : Script
if (canvas) if (canvas)
canvas.SetActive(false); canvas.SetActive(false);
Application.FixDeltaTime = Time.DefaultFixDeltaTime; Application.FixDeltaTime = Time.DefaultFixDeltaTime;
AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale;
} }
}); });
} }
@ -106,6 +107,7 @@ public class PauseMenu : Script
if (canvas) if (canvas)
canvas.SetActive(true); canvas.SetActive(true);
Application.FixDeltaTime = 0; Application.FixDeltaTime = 0;
AnimationSystem.TimeScale = 0;
} }
} }

View File

@ -15,17 +15,14 @@ public abstract class BaseState
} }
public virtual void OnEnter() public virtual void OnEnter()
{ {}
}
public abstract void update(); public abstract void update();
public abstract void fixedUpdate(); public abstract void fixedUpdate();
public virtual void OnExit() public virtual void OnExit()
{ {}
}
public string GetStateName() public string GetStateName()
{ {
@ -37,11 +34,6 @@ public abstract class BaseState
return animationName; return animationName;
} }
public virtual float GetAnimPercent()
{
return 1.0f;
}
public virtual void onCollisionEnter(CollisionInfo info) public virtual void onCollisionEnter(CollisionInfo info)
{ {
} }

View File

@ -113,14 +113,15 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>(); SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>(); SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>(); SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>(); SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHAnimationControllerEditor>(); SHEditorWindowManager::CreateEditorWindow<SHAnimationControllerEditor>();
SHEditorWindowManager::CreateEditorWindow<SHRawAnimInspector>(); SHEditorWindowManager::CreateEditorWindow<SHRawAnimInspector>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
//Add popup windows //Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>(); SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();