From b9a573a97d0e888042ff7b9579c0029989a1c2ca Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Wed, 23 Feb 2022 07:57:18 -0600 Subject: [PATCH] fixed an interaction between slide and fall --- .../DebugMoveState/DebugSlide/dMoveCrouchState.cs | 10 ++++++---- .../DebugMoveState/DebugSlide/dMoveSlideState.cs | 6 +++--- .../MovementState/Slide/MoveCrouchState.cs | 10 ++++++---- .../MovementState/Slide/MoveSlideState.cs | 6 +++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveCrouchState.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveCrouchState.cs index bff9593..bdb153b 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveCrouchState.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveCrouchState.cs @@ -15,7 +15,8 @@ public class dMoveCrouchState : dMoveBaseState if(previousState != mSM.SlideState){ mSM.pStats.CurVel = 0; mSM.moveController.height *= .5f; - mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0)); + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0); + //mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0)); layerMask = 1 << 3; layerMask = ~layerMask; } @@ -27,7 +28,8 @@ public class dMoveCrouchState : dMoveBaseState if(nextState != mSM.CrouchWalkState){ mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0); mSM.pStats.CurVel = mSM.calculatedCurVel; - mSM.moveController.height *= 2.0f; + mSM.moveController.height *= 2.0f; + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0); } } @@ -49,12 +51,12 @@ public class dMoveCrouchState : dMoveBaseState //Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red); - /* + //If falling stop sliding and go to wasd states if(mSM.aSM.currentState == mSM.aSM.FallingState){ mSM.SwitchState(mSM.IdleState); } - */ + } public override void FixedUpdateState(dMoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveSlideState.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveSlideState.cs index 434e50f..9a08b84 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveSlideState.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/DebugSlide/dMoveSlideState.cs @@ -16,7 +16,8 @@ public class dMoveSlideState : dMoveBaseState originalTraction = mSM.pStats.Traction; mSM.moveController.height *= .5f; mSM.pStats.Traction = 0.01f; - mSM.moveController.Move(new Vector3(0,-0.1f,0)); + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0); + //mSM.moveController.Move(new Vector3(0,-0.1f,0)); layerMask = 1 << 3; layerMask = ~layerMask; } @@ -29,6 +30,7 @@ public class dMoveSlideState : dMoveBaseState mSM.pStats.CurVel = mSM.calculatedCurVel; mSM.pStats.Traction = originalTraction; mSM.moveController.height *= 2.0f; + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0); } //if state is crouch revert traction @@ -70,7 +72,6 @@ public class dMoveSlideState : dMoveBaseState //Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red); - /* //If falling stop sliding and go to wasd states if(mSM.aSM.currentState == mSM.aSM.FallingState){ //Determine which state to go into based on player speed @@ -84,7 +85,6 @@ public class dMoveSlideState : dMoveBaseState mSM.SwitchState(mSM.RunState); } } - */ } diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveCrouchState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveCrouchState.cs index 797ab90..14cadfa 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveCrouchState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveCrouchState.cs @@ -15,7 +15,8 @@ public class MoveCrouchState : MoveBaseState if(previousState != mSM.SlideState){ mSM.pStats.CurVel = 0; mSM.moveController.height *= .5f; - mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0)); + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0); + //mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0)); layerMask = 1 << 3; layerMask = ~layerMask; } @@ -27,7 +28,8 @@ public class MoveCrouchState : MoveBaseState if(nextState != mSM.CrouchWalkState){ mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0); mSM.pStats.CurVel = mSM.calculatedCurVel; - mSM.moveController.height *= 2.0f; + mSM.moveController.height *= 2.0f; + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0); } } @@ -49,12 +51,12 @@ public class MoveCrouchState : MoveBaseState //Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red); - /* + //If falling stop sliding and go to wasd states if(mSM.aSM.currentState == mSM.aSM.FallingState){ mSM.SwitchState(mSM.IdleState); } - */ + } public override void FixedUpdateState(MoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveSlideState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveSlideState.cs index 7bcd5e8..c688438 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveSlideState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/Slide/MoveSlideState.cs @@ -16,7 +16,8 @@ public class MoveSlideState : MoveBaseState originalTraction = mSM.pStats.Traction; mSM.moveController.height *= .5f; mSM.pStats.Traction = 0.01f; - mSM.moveController.Move(new Vector3(0,-0.1f,0)); + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0); + //mSM.moveController.Move(new Vector3(0,-0.1f,0)); layerMask = 1 << 3; layerMask = ~layerMask; } @@ -29,6 +30,7 @@ public class MoveSlideState : MoveBaseState mSM.pStats.CurVel = mSM.calculatedCurVel; mSM.pStats.Traction = originalTraction; mSM.moveController.height *= 2.0f; + mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0); } //if state is crouch revert traction @@ -70,7 +72,6 @@ public class MoveSlideState : MoveBaseState //Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red); - /* //If falling stop sliding and go to wasd states if(mSM.aSM.currentState == mSM.aSM.FallingState){ //Determine which state to go into based on player speed @@ -84,7 +85,6 @@ public class MoveSlideState : MoveBaseState mSM.SwitchState(mSM.RunState); } } - */ }