mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Animation Controller
-Added rough animator diagram--needs more work -Added a animator manager script to handle animation priority
This commit is contained in:
@@ -8,7 +8,7 @@ public class dDashCooldownState : dDashBaseState
|
||||
|
||||
public override void EnterState(dDashStateManager dSM, dDashBaseState previousState){
|
||||
cooldown = false; // sets cooldown
|
||||
dSM.StartCoroutine(startCoolDown(dSM)); // activates cooldown
|
||||
//dSM.StartCoroutine(startCoolDown(dSM)); // activates cooldown
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
|
||||
@@ -14,10 +14,12 @@ public class dDashDashingState : dDashBaseState
|
||||
|
||||
public override void EnterState(dDashStateManager dSM, dDashBaseState previousState){
|
||||
currentDashTime = 0; // resets dash time
|
||||
dSM.GetComponent<Animator>().SetBool("isDashing", true);
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
moveDirection = Vector3.zero; // resets moveDirection
|
||||
dSM.GetComponent<Animator>().SetBool("isDashing", false);
|
||||
}
|
||||
|
||||
public override void UpdateState(dDashStateManager dSM){
|
||||
|
||||
@@ -18,13 +18,15 @@ public class dDashStateManager : NetworkBehaviour
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Animator animator; // Animation Controller
|
||||
public Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public dMoveStateManager mSM; // movement state manager
|
||||
public CoolDown driver; // cooldown driver
|
||||
//// AnimatorManagerScript
|
||||
private AnimationManager animationManager;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
@@ -36,6 +38,7 @@ public class dDashStateManager : NetworkBehaviour
|
||||
////Initialize Player Components
|
||||
moveController = GetComponent<CharacterController>(); // set Character Controller
|
||||
animator = GetComponent<Animator>(); // set animator
|
||||
animationManager = GetComponent<AnimationManager>();
|
||||
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
|
||||
////
|
||||
|
||||
@@ -77,6 +80,8 @@ public class dDashStateManager : NetworkBehaviour
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
//update current animation priorty in animation manager
|
||||
animationManager.updateCurrentPriority();
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ using UnityEngine;
|
||||
public class dMoveIdleState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isIdle", true);
|
||||
Debug.Log("Entered Idle");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isIdle", false);
|
||||
Debug.Log("Exited Idle");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -5,11 +5,13 @@ using UnityEngine;
|
||||
public class dMoveJogState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isJogging", true);
|
||||
Debug.Log("Entered Jog");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isJogging", false);
|
||||
Debug.Log("Exited Jog");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -5,11 +5,13 @@ using UnityEngine;
|
||||
public class dMoveRunState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isRunning", true);
|
||||
Debug.Log("Entered Run");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isRunning", false);
|
||||
Debug.Log("Exit Run");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -4,12 +4,17 @@ using UnityEngine;
|
||||
|
||||
public class dMoveWalkState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
//set reference to animator in mSM for each manager
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
//get component is semi expensive--may want to ahve all statemanagers have a reference to animator
|
||||
mSM.GetComponent<Animator>().SetBool("isWalking", true);
|
||||
Debug.Log("Entered Walk");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
|
||||
mSM.GetComponent<Animator>().SetBool("isWalking", false);
|
||||
Debug.Log("Exited Walk");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -37,12 +37,14 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
public CharacterController moveController; // Character Controller
|
||||
public Rigidbody rB; // Players Rigidbody
|
||||
public CapsuleCollider capCol; // Players Capsule Collider
|
||||
private Animator animator; // Animation Controller
|
||||
public Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public dAerialStateManager aSM;
|
||||
//// AnimatorManagerScript
|
||||
private AnimationManager animationManager;
|
||||
////
|
||||
|
||||
////State Transition Variables
|
||||
@@ -87,6 +89,7 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
capCol.enabled = true;
|
||||
parentObj = transform.parent.gameObject; // set parent object
|
||||
animator = GetComponent<Animator>(); // set animator
|
||||
animationManager = GetComponent<AnimationManager>();
|
||||
////
|
||||
|
||||
////Initialize Scripts
|
||||
@@ -151,6 +154,8 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
//update current animation priorty in animation manager
|
||||
animationManager.updateCurrentPriority();
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,15 @@ public class dNitroStateManager : NetworkBehaviour
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
public Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public dMoveStateManager mSM; // move state manager
|
||||
public CoolDown driver; // cooldown driver
|
||||
//// AnimatorManagerScript
|
||||
private AnimationManager animationManager;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
@@ -41,6 +43,7 @@ public class dNitroStateManager : NetworkBehaviour
|
||||
public float nitroVelBoost = 40;
|
||||
public float nitroAccBoost = .4f;
|
||||
|
||||
|
||||
void Awake(){
|
||||
|
||||
////Initialize Player Components
|
||||
@@ -50,6 +53,7 @@ public class dNitroStateManager : NetworkBehaviour
|
||||
capCol.enabled = true;
|
||||
parentObj = transform.parent.gameObject; // set parent object
|
||||
animator = GetComponent<Animator>(); // set animator
|
||||
animationManager = GetComponent<AnimationManager>();
|
||||
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
|
||||
////
|
||||
|
||||
@@ -91,6 +95,8 @@ public class dNitroStateManager : NetworkBehaviour
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
//update current animation priorty in animation manager
|
||||
animationManager.updateCurrentPriority();
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class dOffenseKickState : dOffenseBaseState
|
||||
oSM.leg.SetActive(true); // activate leg
|
||||
kicked = false; // haven't kicked
|
||||
|
||||
oSM.animator.SetBool("IsKicking", true);
|
||||
//start kicking routine
|
||||
oSM.StartCoroutine(kicking(1f));
|
||||
}
|
||||
@@ -22,6 +23,7 @@ public class dOffenseKickState : dOffenseBaseState
|
||||
legRotation = 0; // reset leg angle
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
oSM.leg.SetActive(false); // reset leg angle
|
||||
oSM.animator.SetBool("IsKicking", false);
|
||||
}
|
||||
|
||||
public override void UpdateState(dOffenseStateManager oSM){
|
||||
|
||||
@@ -5,6 +5,7 @@ using MLAPI;
|
||||
|
||||
public class dOffenseStateManager : NetworkBehaviour
|
||||
{
|
||||
|
||||
////Player States
|
||||
public dOffenseBaseState currentState;
|
||||
public dOffenseBaseState previousState;
|
||||
@@ -31,14 +32,16 @@ public class dOffenseStateManager : NetworkBehaviour
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
public Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public dMoveStateManager mSM; // move state manager
|
||||
public dAerialStateManager aSM; // aerial state manager
|
||||
////
|
||||
//// AnimatorManagerScript
|
||||
private AnimationManager animationManager;
|
||||
///
|
||||
|
||||
void Awake(){
|
||||
|
||||
@@ -48,6 +51,7 @@ public class dOffenseStateManager : NetworkBehaviour
|
||||
capCol = GetComponent<CapsuleCollider>(); // set Capsule Collider
|
||||
capCol.enabled = true;
|
||||
animator = GetComponent<Animator>(); // set animator
|
||||
animationManager = GetComponent<AnimationManager>();
|
||||
////
|
||||
|
||||
////Initialize Player Objects
|
||||
@@ -96,6 +100,8 @@ public class dOffenseStateManager : NetworkBehaviour
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
//update current animation priorty in animation manager
|
||||
animationManager.updateCurrentPriority();
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user