Raccoon animation and scene changes #415

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

View File

@ -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]

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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<RigidBody>();
if (!rb)
Debug.LogError("RigidBody is NULL!");
Debug.LogError("RigidBody is MISSING!");
//Transform check
tranform = GetComponent<Transform>();
if(!tranform)
Debug.LogError("tranform is NULL!");
Debug.LogError("tranform is MISSING!");
animator = GetComponent<Animator>();
if (!animator)
Debug.LogError("Animator is MISSING!");
stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
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));