mirror of
https://github.com/PashaBibko/The-Mobius-Line.git
synced 2026-04-04 01:49:07 +00:00
Stopped player turning around during wall ride
This commit is contained in:
@@ -631,11 +631,12 @@ MonoBehaviour:
|
|||||||
m_SlideDrag: 3
|
m_SlideDrag: 3
|
||||||
m_SlideSpeed: 10
|
m_SlideSpeed: 10
|
||||||
m_JumpForce: 20
|
m_JumpForce: 20
|
||||||
m_WallRunSpeed: 10
|
m_WallRunSpeed: 15
|
||||||
m_WallCheckDistance: 1.5
|
m_WallCheckDistance: 1.5
|
||||||
m_DistanceOfFloorToWallRide: 0.1
|
m_DistanceOfFloorToWallRide: 0.1
|
||||||
m_JumpKey: 32
|
m_JumpKey: 32
|
||||||
m_SlideKey: 99
|
m_SlideKey: 99
|
||||||
|
m_WallRunKey: 304
|
||||||
m_Body: {fileID: 1174770952}
|
m_Body: {fileID: 1174770952}
|
||||||
m_Orientation: {fileID: 166780449}
|
m_Orientation: {fileID: 166780449}
|
||||||
m_PlayerTransform: {fileID: 1174770951}
|
m_PlayerTransform: {fileID: 1174770951}
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
// Timer for slide boost duration left
|
// Timer for slide boost duration left
|
||||||
int m_TicksOfSlideBoostLeft = 0;
|
int m_TicksOfSlideBoostLeft = 0;
|
||||||
|
|
||||||
|
// Wall riding trackers
|
||||||
|
bool m_FirstFrameWallRiding = true;
|
||||||
|
bool m_FlippedWallRideDirectionFirstFrame = false;
|
||||||
|
|
||||||
// Raycast hit objects
|
// Raycast hit objects
|
||||||
RaycastHit m_GroundHit;
|
RaycastHit m_GroundHit;
|
||||||
RaycastHit m_SlopeHit;
|
RaycastHit m_SlopeHit;
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
StopSlide();
|
StopSlide();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PlayerState.WALL_RUNNING:
|
||||||
|
m_FirstFrameWallRiding = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,21 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
// Calculates the foward direction of the wall
|
// Calculates the foward direction of the wall
|
||||||
Vector3 foward = Vector3.Cross(m_WallNormal, transform.up);
|
Vector3 foward = Vector3.Cross(m_WallNormal, transform.up);
|
||||||
|
|
||||||
// Flips the foward direction if facing the other direction
|
if (m_FirstFrameWallRiding == true)
|
||||||
if ((m_Orientation.forward - foward).magnitude > (m_Orientation.forward - (-foward)).magnitude)
|
{
|
||||||
{ foward = -foward; }
|
// Resets the tracker
|
||||||
|
m_FirstFrameWallRiding = false;
|
||||||
|
|
||||||
|
// Calculates it should flip the direction of the wall riding depending on the direction the player is looking
|
||||||
|
bool flip = (m_Orientation.forward - foward).magnitude > (m_Orientation.forward - (-foward)).magnitude;
|
||||||
|
|
||||||
|
// Stores it for all the other frames of the current wall ride
|
||||||
|
m_FlippedWallRideDirectionFirstFrame = flip;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flips the direction if it did the first frame to stop the direction changing mid wall ride
|
||||||
|
if (m_FlippedWallRideDirectionFirstFrame == true)
|
||||||
|
{ foward = -foward; }
|
||||||
|
|
||||||
// Applies the wall running force to the player
|
// Applies the wall running force to the player
|
||||||
m_Body.AddForce(foward * m_WallRunSpeed * m_Body.mass * 10.0f, ForceMode.Force);
|
m_Body.AddForce(foward * m_WallRunSpeed * m_Body.mass * 10.0f, ForceMode.Force);
|
||||||
|
|||||||
Reference in New Issue
Block a user