bug fixes

This commit is contained in:
Melbyj1125
2022-04-27 00:37:38 -05:00
parent 16a02b2332
commit f83d22eab8
16 changed files with 125 additions and 44 deletions

View File

@@ -66,6 +66,8 @@ public class MoveStateManager : NetworkBehaviour
RaycastHit wallHitTop, wallHitBot, wallExitTop, wallExitBot; // Raycast for momentum loss on wall hit
private Vector3 lastVel; // previous vel
private bool firstWallHit = false; // hit the wall for the first time
private float tempCurVel;
private bool setTempVel = false;
//Camera Variables
private Vector3 camRotation; // cameras camera rotation vector
@@ -182,12 +184,45 @@ public class MoveStateManager : NetworkBehaviour
////Broad Functions
//Player Speed Calculator
public float PlayerSpeed(){
//If nothing is pressed speed is 0
if ((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) || pStats.IsPaused)
//If nothing is pressed speed is 0 set a tempVel
if (((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) && !setTempVel) || pStats.IsPaused)
{
if(pStats.CurVel > 0.0f){
tempCurVel = pStats.CurVel;
setTempVel = true;
}
pStats.CurVel = 0.0f;
return pStats.CurVel;
}
//
else if((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) && setTempVel){
tempCurVel -= .35f;
if(tempCurVel <= 0){
setTempVel = false;
tempCurVel = 0;
}
pStats.CurVel = 0.0f;
return pStats.CurVel;
}
else if(tempCurVel > 0){
if(tempCurVel < pStats.MinVel){
pStats.CurVel = pStats.MinVel;
tempCurVel = 0;
setTempVel = false;
return pStats.MinVel;
}
pStats.CurVel = tempCurVel;
tempCurVel = 0;
setTempVel = false;
return pStats.CurVel;
}
//If current speed is below min when pressed set to minimum speed
else if (pStats.CurVel < pStats.MinVel || firstWallHit == true)
{

View File

@@ -34,7 +34,7 @@ public class MoveCrouchState : MoveBaseState
public override void UpdateState(MoveStateManager mSM){
//If player isn't pressing either Q or the joystick button they stop crouching if nothing is above them
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKeyDown(GameManager.GM.bindableActions["slideKey"]))){
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(GameManager.GM.bindableActions["slideKey"]))){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, mSM.layerMask) == false)){

View File

@@ -19,7 +19,7 @@ public class MoveCrouchWalkState : MoveBaseState
}
public override void UpdateState(MoveStateManager mSM){
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKeyDown(GameManager.GM.bindableActions["slideKey"]))){
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(GameManager.GM.bindableActions["slideKey"]))){
mSM.SwitchState(mSM.CrouchState);
}
else if((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f)){

View File

@@ -47,7 +47,7 @@ public class MoveSlideState : MoveBaseState
mSM.pStats.CurTraction += .004f;
//If player isn't pressing either Q or the joystick button they stop sliding if nothing is above them
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKeyDown(GameManager.GM.bindableActions["slideKey"]))){
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(GameManager.GM.bindableActions["slideKey"]))){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, mSM.layerMask) == false)){
//Determine which state to go into based on player speed