diff --git a/Assets/GameObjects/Prefabs/Player.prefab b/Assets/GameObjects/Prefabs/Player.prefab index af88a31..8069412 100644 --- a/Assets/GameObjects/Prefabs/Player.prefab +++ b/Assets/GameObjects/Prefabs/Player.prefab @@ -1738,7 +1738,7 @@ MonoBehaviour: GroundCastLength: 0.2 GroundLayer: serializedVersion: 2 - m_Bits: 10497 + m_Bits: 256 ShowGroundCast: 0 ShowMoveVector: 0 --- !u!1 &7391558913556166741 diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index 37e95a7..515124a 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -293,9 +293,11 @@ namespace NeonTea.Quakeball.Players { GravitationalVelocity += Physics.gravity * Time.deltaTime; } + Vector3 GroundNormal = GroundCast(); + float FrictionVelocityFactor = Mathf.Max(GroundVelocity.magnitude, MoveStyle.StopVelocity); float Deccel = FrictionVelocityFactor * Time.deltaTime; - if (Grounded) { + if (Grounded || GroundNormal != Vector3.up) { Deccel *= MoveStyle.Friction; } else { Deccel *= MoveStyle.AirFriction; @@ -303,11 +305,10 @@ namespace NeonTea.Quakeball.Players { float FrictionedVelocity = Mathf.Max(0, GroundVelocity.magnitude - Deccel); GroundVelocity = GroundVelocity.normalized * FrictionedVelocity; - Vector3 GroundNormal = GroundCast(); Vector3 FixedHeading = Vector3.ProjectOnPlane(MoveDirection, GroundNormal).normalized; float CurrentSpeed = Vector3.Dot(GroundVelocity, FixedHeading); float Acceleration = MoveStyle.TargetVelocity * Time.deltaTime; - if (Grounded) { + if (Grounded || GroundNormal != Vector3.up) { Acceleration *= MoveStyle.Acceleration; } else { Acceleration *= MoveStyle.AirAcceleration; @@ -315,8 +316,7 @@ namespace NeonTea.Quakeball.Players { Acceleration = Mathf.Min(Acceleration, MoveStyle.TargetVelocity - CurrentSpeed); GroundVelocity += FixedHeading * Acceleration; - CharacterController.Move(GroundVelocity * Time.deltaTime); - CollisionFlags flags = CharacterController.Move(GravitationalVelocity * Time.deltaTime); + CharacterController.Move((GravitationalVelocity + GroundVelocity) * Time.deltaTime); if (CharacterController.isGrounded) { GroundedTime = Time.time; LatestGroundedY = transform.position.y; @@ -325,6 +325,7 @@ namespace NeonTea.Quakeball.Players { // Hit a roof while jumping, reset falling velocity downwards (same as "static gravity" when grounded) GravitationalVelocity.y = GroundCastLength; } + if (ShowMoveVector) { Debug.DrawLine(transform.position + CharacterController.center, transform.position + CharacterController.center + GravitationalVelocity, Color.yellow, 1.0f); Debug.DrawLine(transform.position + CharacterController.center, transform.position + CharacterController.center + GroundVelocity, Color.green, 1.0f);