Merge branch 'animationController' into main

This commit is contained in:
Evan Nydahl 2022-03-07 11:26:13 -06:00
commit ab552e5467
16 changed files with 1225 additions and 123 deletions

View File

@ -0,0 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationManager : MonoBehaviour
{
//current priority weight
//priority 0: priority value of offense and aerial state when not active (should never be current priority)-- is grounded/ incapactiatated, None, and cooldown
//priority 1: ground state (nothing else active)
//priority 2: aerial state (nothing above it)
//priority 3: offense state (nothing above it)
//priority 4: dash state (nothing above it)
//priority 5: incapacitated state
//highest priority/currently active animations;
private int currentPriority = 1;
//declare references to all the state managers
private dOffenseStateManager offenseState;
private dNitroStateManager nitroState;
private dMoveStateManager moveState;
private dDashStateManager dashState;
private dAerialStateManager aerialState;
//declare reference to animator
private Animator animator;
//retrieve all state managers
private void Awake()
{
//initialize all state managers references
offenseState = GetComponent<dOffenseStateManager>();
nitroState = GetComponent<dNitroStateManager>();
moveState = GetComponent<dMoveStateManager>();
dashState = GetComponent<dDashStateManager>();
aerialState = GetComponent<dAerialStateManager>();
animator = GetComponent<Animator>();
}
//this function will be called everytime a state is switched. If the new state change would change the current priority number,
//then the current priorty will changed
//Note: if we ever want to have this manager keep track of current animation state and not just a priorty number,
//then this will need to be changed later (also if we want to add additional animations)
public void updateCurrentPriority(){
int highestPriority;
//check if MoveStateManager's current state is incapcitated state
if (moveState.currentState.GetType() == typeof(dMoveRagdollState) || moveState.currentState.GetType() == typeof(dMoveRecoveringState)){
highestPriority = 5;
}
//if dash manager current state is dashing
else if (dashState.currentState.GetType() == typeof(dDashDashingState)){
highestPriority = 4;
}
//check to see if offense manager current state is any state that's doesn't have a weight of 0;
else if (offenseState.currentState.GetType() != typeof(dOffenseIncapacitatedState) && offenseState.currentState.GetType() != typeof(dOffenseNoneState) && offenseState.currentState.GetType() != typeof(dOffenseCooldownState)){
highestPriority = 3;
}
//if current state in aerialManager is not grounded
else if (aerialState.currentState.GetType() != typeof(dAerialGroundedState)){
highestPriority = 2;
}
//ground movement is the only state with a animation right now
else{
highestPriority = 1;
}
//if highest priorty does not equal current, then a state changed has resulted in a new higher priorty animation
if(highestPriority != currentPriority){
currentPriority = highestPriority;
animator.SetInteger("currentPriority", currentPriority);
}
}
//function will set the currentPriorty to the newPriority arguement.
//Note: this function is mostly meant to exist if we need to force a new priorty for some reason, otherwise lgoci will be handled in check
public void SetCurrentPriorityState(int newPriority){
//set var to new prio
currentPriority = newPriority;
//set animator priority var
animator.SetInteger("currentPriority", currentPriority);
}
//return priority of a given state (stubbed out for not as not needed for current implementation but may be desired later)
public int GetCurrentPriortyValue(){
return 0;
}
//retrieve highest priority value (current priorty should almost always be
public int GetHighestPriorityValue(){
return currentPriority;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db0579f1149ac2f4295639b1c9430bf6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -162,7 +162,7 @@ Transform:
- {fileID: 8200857314457501958}
- {fileID: 4801201675622690668}
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &45642691
GameObject:
@ -257,6 +257,23 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &59641869 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1707207228499037409, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
m_PrefabInstance: {fileID: 878836005}
m_PrefabAsset: {fileID: 0}
--- !u!114 &59641870
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 59641869}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: db0579f1149ac2f4295639b1c9430bf6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &128722833
GameObject:
m_ObjectHideFlags: 0
@ -430,7 +447,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 197.763, z: 0}
--- !u!1 &310775963
GameObject:
@ -525,7 +542,7 @@ Transform:
m_LocalScale: {x: 243.4848, y: 10, z: 100}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &689939137
PrefabInstance:
@ -536,7 +553,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: -8679921383154817045, guid: d583fb6b27d23a849b80c1ea7d813943, type: 3}
propertyPath: m_RootOrder
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: d583fb6b27d23a849b80c1ea7d813943, type: 3}
propertyPath: m_LocalPosition.x
@ -630,75 +647,67 @@ Transform:
m_Father: {fileID: 988955191}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &864409373
--- !u!1001 &878836005
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalPosition.x
value: 52.246025
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalPosition.y
value: 5
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalPosition.z
value: -18.84113
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 297879044457584256, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3039877022422189067, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: m_Name
value: DebugPlayerPrefab 1
objectReference: {fileID: 0}
- target: {fileID: 6664667533527261801, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
- target: {fileID: 1707207228499037468, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: hasDash
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6664667533527261801, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: hasNitro
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_RootOrder
value: 11
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalPosition.x
value: 33
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalPosition.y
value: 19.385002
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalPosition.z
value: -11.2
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6664667533527261801, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
propertyPath: hardCapMaxVel
value: 60
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7053551988629990270, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_Name
value: DebugSMPlayerPrefab
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 6adb8bcc65ee3a54da64d7c65225f219, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
--- !u!1 &988955190
GameObject:
m_ObjectHideFlags: 0
@ -732,7 +741,7 @@ Transform:
- {fileID: 1364344412}
- {fileID: 128722834}
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1099726822
GameObject:
@ -828,7 +837,7 @@ Transform:
m_LocalScale: {x: 4, y: 4, z: 4}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1364344411
GameObject:
@ -7927,7 +7936,7 @@ Transform:
- {fileID: 7166745667220549356}
- {fileID: 7674073525341041895}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4717015385984152624
GameObject:
@ -9202,7 +9211,7 @@ Transform:
- {fileID: 1238986339987449071}
- {fileID: 4381207511937094485}
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 353.008, z: 0}
--- !u!1 &5464757302679342334
GameObject:
@ -11480,7 +11489,7 @@ Transform:
- {fileID: 1695416246655401831}
- {fileID: 6083860270965389840}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &7215587182093335156
MeshRenderer:
@ -11891,7 +11900,7 @@ Transform:
- {fileID: 5203016803932664549}
- {fileID: 3404700905833877519}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0}
--- !u!33 &7422091022867816153
MeshFilter:

View File

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

View File

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

View File

@ -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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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
@ -88,6 +90,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
@ -165,6 +168,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);
}

View File

@ -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);
}
}

View File

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

View File

@ -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);
}

View File

@ -9,7 +9,7 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c731f1415016439262f2434