mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Implemented Crouch walking
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user