/// <summary> /// Applies correct jumping actions base on jump type /// </summary> void WallJump() { isWallRunning = false; if (wallSide == 0) { wallJumpAngle = 180; wallJumpForce = rayDir * jumpForce; movementSpeeds.y = jumpForce; wallJumpType = WallJumps.vertical; onWallRotation = myTransform.eulerAngles.y - 180; } else { if (wallJumpType == WallJumps.wallLeap) { wallJumpAngle = 90; movementSpeeds.y = jumpForce / 1.5f; movementSpeeds.z = jumpForce * 2; } else if (wallJumpType == WallJumps.wallSwap) { movementSpeeds.y = jumpForce / 2.0f; movementSpeeds.z = runSpeed; movementSpeeds.x = (jumpForce * wallSide) * 2; } else if (wallJumpType == WallJumps.sideWall) { wallJumpAngle = 25; movementSpeeds.y = jumpForce; movementSpeeds.z = jumpForce * 1.5f; movementSpeeds.x = jumpForce * wallSide; } GetSide(wallJumpAngle); } }
/// <summary> /// Determine the type of jump. /// </summary> void GetTypeOfJump() { // Determine against camera angle wallJump = true; if (input.z < -0.5) { wallJumpType = WallJumps.wallLeap; } else if (Mathf.Abs(input.x) > 0.5f) { wallJumpType = WallJumps.wallSwap; } else { wallJumpType = WallJumps.sideWall; } Invoke("WallJump", 0.2f); wallJumpDelay = 0.25f; }
/// <summary> /// Input controller /// </summary> void Inputs() { isLanding = false; isFalling = false; if (input == Vector3.zero) { isNotMoving = true; } else { isNotMoving = false; } if (Input.GetAxisRaw("RightBumper") != 0 && !rbPressed) { myCam.hasLockOnTarget = !myCam.hasLockOnTarget; rbPressed = true; } else if (Input.GetAxisRaw("RightBumper") == 0) { rbPressed = false; } if (grounded) { wallJumpForce = Vector3.zero; wallJumpAngle = 0; wallJumpType = WallJumps.none; movementSpeeds.x = 0; wallJump = false; if (Input.GetAxis("AutoMove") == 0) { isWallRunning = false; verticalWallRun = false; wallRunReleased = true; } if (Input.GetAxis("AutoMove") != 0 && !isWallRunning && canWallRun && wallRunReleased && input != Vector3.zero) { isWallRunning = true; movementSpeeds.y = wallRunForce; } else if (Input.GetAxis("Jump") != 0) { jumping = true; Invoke("JumpDelay", 0.2f); } else if (!jumping) { movementSpeeds.y = 0; isWallRunning = false; } } else if (Input.GetAxis("AutoMove") != 0 && canWallRun) { wallJumpAngle = 0; isWallRunning = true; wallRunReleased = false; if (Input.GetAxis("Jump") != 0 && !wallJump) { GetTypeOfJump(); } else if (wallJumpDelay <= 0) { wallJump = false; wallJumpType = WallJumps.none; } } else { FallingOrLanding(); } if ((Input.GetAxisRaw("LTrigger") != 0 || Input.GetKeyDown(KeyCode.E)) && abilityTimer <= 0) { teleportVisual = true; DistCheck(); } if (teleportVisual && Input.GetAxisRaw("LTrigger") == 0) { hasTeleported = true; abilityTimer = abilityCoolDown; } }