Implemented Crouch walking

This commit is contained in:
Melbyj1125
2022-04-08 15:21:24 -05:00
parent 562b64b160
commit fdc77ada48
9 changed files with 135 additions and 63 deletions

View File

@@ -220,6 +220,41 @@ public class MoveStateManager : NetworkBehaviour
}
}
public void CrouchMovement(){
//Keyboard inputs
//Checks if movement keys have been pressed and calculates correct vector
if(currentState == CrouchWalkState){
float curSpeed = PlayerSpeed();
if(curSpeed != 0){
moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * 2;
moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * 2;
}
else{
moveX = Vector3.zero;
moveZ = Vector3.zero;
}
vel = moveX + moveZ;
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, 10 * Time.deltaTime);
if(currentState == GrappleAirState){
driftVel = Vector3.zero;
}
if(driftVel != Vector3.zero){
playerModel.transform.rotation = Quaternion.LookRotation(driftVel.normalized);
}
//Actually move he player
moveController.Move(driftVel);
}
else{
moveController.Move(Vector3.zero);
}
}
//Wasd movement using player speed
public void DirectionalMovement(){
//Keyboard inputs
@@ -272,11 +307,6 @@ public class MoveStateManager : NetworkBehaviour
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
//Need to have movecontroller involved for correct movement
if(currentState == CrouchState){
driftVel = Vector3.zero;
}
//Actually move he player
moveController.Move(driftVel);
}