Wallrun allows players to hop off wall again

This commit is contained in:
Melbyj1125
2021-12-03 10:51:37 -06:00
parent 57385b47b4
commit 55885e2ef1
19 changed files with 59 additions and 101 deletions

View File

@@ -32,6 +32,7 @@ public class dWallRun : NetworkBehaviour
float elapsedTimeSinceJump = 0;
float elapsedTimeSinceWallAttach = 0;
float elapsedTimeSinceWallDetatch = 0;
bool attachOnce = false;
bool jumping;
bool isPlayergrounded() => playerMovementController.isGrounded;
@@ -159,7 +160,6 @@ public class dWallRun : NetworkBehaviour
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
moveToSet.x = (moveToSet.x * -velNorm.x);
Debug.Log("x");
}
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
moveToSet.x = (-moveToSet.x * -velNorm.x);
@@ -167,7 +167,6 @@ public class dWallRun : NetworkBehaviour
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
moveToSet.z = (moveToSet.z * -velNorm.z);
Debug.Log("z");
}
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
moveToSet.z = (-moveToSet.z * -velNorm.z);
@@ -178,6 +177,11 @@ public class dWallRun : NetworkBehaviour
playerMovementController.SetPlayerVelocity(moveToSet);
isWallRunning = true;
if(!attachOnce && playerMovementController.curJumpNum != 0){
playerMovementController.curJumpNum = playerMovementController.curJumpNum - 2 ;
attachOnce = true;
}
}
}

View File

@@ -26,7 +26,7 @@ public class dPlayerMovement : NetworkBehaviour
private CharacterController moveController;
//Jump value
private int curJumpNum;
public int curJumpNum;
private bool jumpPressed;
bool tempSet = false;
float tempTraction = 0.0f;
@@ -261,7 +261,13 @@ public class dPlayerMovement : NetworkBehaviour
//If space is pressed apply an upwards force to the player
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
{
AddImpact(transform.up, pStats.JumpPow);
if(wallRun.IsWallRunning()){
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow);
}
else{
AddImpact(transform.up, pStats.JumpPow);
}
curJumpNum++;
jumpPressed = true;
}
@@ -357,6 +363,10 @@ public class dPlayerMovement : NetworkBehaviour
//Wallrunning
else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
else{
vel.y -= pStats.PlayerGrav * Time.deltaTime;
}
//If gliding
//Go down slowly
}