void CheckForPlayerGroundPos() { RayProp prop = IsGroundHit(); if (prop != null) { if (movInputInvoked) { Vector3 playerMovDir = (transform.position - lastPlayerPos).normalized; if (playerMovDir.x != 0 && IsWallHit() == null) { playerRot = rotAmt; } } prop = IsSlatedPlatformHit(); if (prop != null) { if (Vector2.Angle(Vector2.up, prop.hitInfo.normal) > 0 && !movInputInvoked) { playerVel = Vector2.zero; playerRot = 0; } } TakeJumpInput(); } else { CheckForRotDirAndApplyRot(); CancelJumpingUp(); } }
private RayProp IsWallHit() { RayProp prop = IsSideLeftWallHit(); if (prop != null) { return(prop); } prop = IsSideRightWallHit(); if (prop != null) { return(prop); } return(null); }
void ProcessJumping() { if (!onGround) { if (jumpingUp) { playerVel = playerVel + (Vector2.up * jumpUpSpeed); if (IsCealingHit() != null) { CancelJumpingUp(); } } else { playerVel = playerVel + (-Vector2.up * comeDownSpeed); } } else { RayProp prop = IsSlatedPlatformHit(); if (prop != null) { if (Vector2.Angle(Vector2.up, prop.hitInfo.normal) > 0 && !movInputInvoked) { playerVel = Vector2.zero; } else { playerVel = playerVel + (-Vector2.up * comeDownSpeed); } } else { playerVel = playerVel + (-Vector2.up * comeDownSpeed); } } }