Changed how slope detection works

There is a bug with the camera
This commit is contained in:
Pasha Bibko
2025-03-30 17:26:31 +01:00
parent 86acfab81d
commit 8610868924
7 changed files with 129 additions and 91 deletions

View File

@@ -43,11 +43,13 @@ public partial class PlayerMovement : MonoBehaviour
private void Update()
{
// Performs raycasts to see what the player is standing on
m_Grounded = Physics.Raycast(transform.position, Vector3.down, out m_GroundHit, m_PlayerHeight * 0.5f + 0.3f, m_GroundMask);
m_OnSlope = Physics.Raycast(transform.position, Vector3.down, out m_SlopeHit, m_PlayerHeight * 0.5f + 0.3f, m_SlopeMask);
m_Grounded = Physics.Raycast(transform.position, Vector3.down, out m_StandingOn, m_PlayerHeight * 0.5f + 0.3f, m_GroundMask);
m_OnSlope = m_StandingOn.normal != new Vector3(0.0f, 1.0f, 0.0f) && m_Grounded;
Debug.Log(m_OnSlope + " | " + m_StandingOn.normal);
// Checks the player is far enough of the ground to start wall running
m_IsFarEnoughOffGroundToWallRide = m_GroundHit.distance > m_DistanceOfFloorToWallRide;
m_IsFarEnoughOffGroundToWallRide = m_StandingOn.distance > m_DistanceOfFloorToWallRide;
// Updates the state of the user input
UpdateInput();