Changes to debug and state machine

This commit is contained in:
Melbyj1125
2022-03-07 12:02:37 -06:00
parent 71d7a84725
commit b9ff40688b
10 changed files with 31 additions and 22 deletions

View File

@@ -6,13 +6,12 @@ public class MoveRagdollState : MoveBaseState
{
float ragTime; // ragdoll timer
Vector3 prevRot; // previous rotation before ragdolled
bool beginRagTimer = false; // whether ragtimer has started
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
ragTime = mSM.pStats.RecovTime; // how long to be ragdolled
prevRot = mSM.transform.localEulerAngles; // save previous rotation
mSM.prevRot = mSM.transform.localEulerAngles; // save previous rotation
mSM.capCol.enabled = true; // enable capsule collider
mSM.moveController.enabled = false; // disable move controller
mSM.rB.isKinematic = false; // disable kinematic
@@ -24,12 +23,6 @@ public class MoveRagdollState : MoveBaseState
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
mSM.pStats.GravVel = 80; // resets gravVel
mSM.capCol.enabled = false; // disable capsule collider
mSM.moveController.enabled = true; // enable move controller
mSM.rB.isKinematic = true; // enable kinematic
mSM.rB.detectCollisions = false; // detect collisions false
mSM.transform.localEulerAngles = prevRot; // reset player rotation
}
public override void UpdateState(MoveStateManager mSM){

View File

@@ -7,7 +7,14 @@ public class MoveRecoveringState : MoveBaseState
////// ADD SOMETHING THAT CHECKS ANIMATION FINISH BEFORE GO TO IDLE
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
mSM.pStats.GravVel = 50; // resets gravVel
mSM.capCol.enabled = false; // disable capsule collider
mSM.moveController.enabled = true; // enable move controller
mSM.rB.isKinematic = true; // enable kinematic
mSM.rB.detectCollisions = false; // detect collisions false
mSM.transform.localEulerAngles = mSM.prevRot; // reset player rotation
mSM.CancelMomentum(); // reset player variables
mSM.moveController.Move(new Vector3(0,2,0));
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){

View File

@@ -76,6 +76,7 @@ public class MoveStateManager : NetworkBehaviour
//Ragdoll Variables
public Vector3 dirHit; // Direction hit
public float distToGround; // distance to ground
public Vector3 prevRot; // previous rotation before ragdolled
////
@@ -213,18 +214,20 @@ public class MoveStateManager : NetworkBehaviour
//Raycast offset
Vector3 rayOffset = moveXZ - lastVel;
/*
//Check if wall is in direction player is moving
if (((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized, out wallHitBot, .2f, layerMask) == true) || ((currentState != SlideState || currentState != CrouchState) && (Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), moveXZ.normalized, out wallHitTop, .2f, layerMask) == true))) && !firstWallHit){
if (((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized, out wallHitBot, .2f, layerMask) == true) || ((Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), moveXZ.normalized, out wallHitTop, .2f, layerMask) == true))) && !firstWallHit){
CancelMomentum();
firstWallHit = true;
}
else if((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized, out wallHitBot, .2f, layerMask) == false) || ((currentState != SlideState || currentState != CrouchState) && (Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), moveXZ.normalized, out wallHitTop, .2f, layerMask) == false))){
else if((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized, out wallHitBot, .2f, layerMask) == false) || ((Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), moveXZ.normalized, out wallHitTop, .2f, layerMask) == false))){
firstWallHit = false;
}
Debug.DrawRay(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized * 1f, Color.red);
Debug.DrawRay(gameObject.transform.position + new Vector3(0,2.2f,0) + rayOffset, moveXZ.normalized * 1f, Color.red);
*/
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
if(currentState == GrappleAirState){
driftVel = Vector3.zero;

View File

@@ -8,7 +8,6 @@ public class OffenseCooldownState : OffenseBaseState
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
cooldown = false; // cooldown isn't over
//start cooldown
oSM.StartCoroutine(kickCooldown());
}

View File

@@ -36,7 +36,6 @@ public class OffenseNoneState : OffenseBaseState
//if in the air
else if((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && !oSM.pStats.IsPaused){
//if power is above 300 air punch
if(oSM.pStats.KickPow > 300){
oSM.SwitchState(oSM.AirPunchState);

View File

@@ -116,6 +116,9 @@ public class OffenseStateManager : NetworkBehaviour
if(collision.transform.CompareTag("ArcherTarget") && myCollider == legHitbox.GetComponent<Collider>()){
Vector3 direction = this.transform.forward;
Debug.Log("---Player Being Kicked: " + collision.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
Debug.Log("---Player Kicking: " + this.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
ulong netObjID = collision.gameObject.transform.root.GetComponent<NetworkObject>().NetworkObjectId;
ApplyKickServerRPC(direction, netObjID);
}
@@ -149,6 +152,7 @@ public class OffenseStateManager : NetworkBehaviour
foreach(GameObject kickedPlayer in players){
//First check if the player is kicked
if(kickedPlayer.transform.root.GetComponent<NetworkObject>() != null && kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId == netObjId && kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId != this.transform.root.GetComponent<NetworkObject>().NetworkObjectId){
Debug.Log("Kicking other user");
kickedPlayer.GetComponent<MoveStateManager>().GetHit(direction, 10);
}