mirror of
https://github.com/PashaBibko/The-Mobius-Line.git
synced 2026-04-04 01:49:07 +00:00
Changed how slope detection works
There is a bug with the camera
This commit is contained in:
@@ -12,6 +12,7 @@ public class CameraController : MonoBehaviour
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] Transform m_Orientation;
|
||||
[SerializeField] Transform m_Tracking;
|
||||
|
||||
// Private variables //
|
||||
|
||||
@@ -65,5 +66,8 @@ public class CameraController : MonoBehaviour
|
||||
// Applies the rotation to the objects within Unity
|
||||
m_Orientation.rotation = Quaternion.Euler(0, m_Rotation.y, 0);
|
||||
transform.rotation = Quaternion.Euler(m_Rotation.x, m_Rotation.y, 0);
|
||||
|
||||
// Sets its location to where it is tracking
|
||||
transform.position = m_Tracking.position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
if (m_OnSlope)
|
||||
{
|
||||
// Calculates better move direction for sliding
|
||||
m_MoveDir = Vector3.ProjectOnPlane(m_MoveDir, m_SlopeHit.normal).normalized;
|
||||
m_MoveDir = Vector3.ProjectOnPlane(m_MoveDir, m_StandingOn.normal).normalized;
|
||||
}
|
||||
|
||||
// Runs correct update function depending on player state
|
||||
|
||||
@@ -15,7 +15,6 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
[Header("Ground Check")]
|
||||
[SerializeField] float m_PlayerHeight;
|
||||
[SerializeField] LayerMask m_GroundMask;
|
||||
[SerializeField] LayerMask m_SlopeMask;
|
||||
|
||||
[Header("Sliding Settings")]
|
||||
[SerializeField] float m_SlideRequiredSpeed;
|
||||
@@ -71,9 +70,8 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
bool m_FlippedWallRideDirectionFirstFrame = false;
|
||||
Vector3 m_LastWallNormal;
|
||||
|
||||
// Raycast hit objects
|
||||
RaycastHit m_GroundHit;
|
||||
RaycastHit m_SlopeHit;
|
||||
// What the player is standing on
|
||||
RaycastHit m_StandingOn;
|
||||
|
||||
//
|
||||
BoxCollider m_WallCollider;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -31,7 +31,7 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
// Correctly applies force on slopes
|
||||
if (m_OnSlope)
|
||||
{
|
||||
Vector3 slopeDir = m_SlopeHit.normal;
|
||||
Vector3 slopeDir = m_StandingOn.normal;
|
||||
slopeDir.y = 0.0f - slopeDir.y;
|
||||
m_Body.AddForce(slopeDir.normalized * m_SlideSpeed * m_Body.mass * 10, ForceMode.Force);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user