From df9cb11446e65d0a0d3aa00d4308e4b34ca95e80 Mon Sep 17 00:00:00 2001 From: Glence Date: Wed, 16 Nov 2022 22:28:08 +0800 Subject: [PATCH] add to vel instead of setting it --- Assets/Scripts/SC_PlayerController.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/SC_PlayerController.cs b/Assets/Scripts/SC_PlayerController.cs index 8ca17674..946ec1d2 100644 --- a/Assets/Scripts/SC_PlayerController.cs +++ b/Assets/Scripts/SC_PlayerController.cs @@ -130,7 +130,7 @@ public class PlayerController : Script GotCaught(); //Debug.Log($"{currentState}"); //Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}"); - //Debug.Log($"X: {rb.LinearVelocity.x}" + $" Y: {rb.LinearVelocity.z}"); + //Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}"); //Debug.Log(currentState.ToString() + " x:" + rb.LinearVelocity.x.ToString() + " y:" + rb.LinearVelocity.y.ToString() + " z:" + rb.LinearVelocity.z.ToString()); } @@ -139,11 +139,6 @@ public class PlayerController : Script //Rotation(); MoveKey(); - - //to be change - if (rb) - rb.AddForce(new Vector3(-rb.GetForce().x, -rb.GetForce().y, -rb.GetForce().z)); - Move(); Sprint(); Jump(); @@ -224,7 +219,7 @@ public class PlayerController : Script if (rb != null) { //rb.AddForce(new Vector3(axisMove.x, 0.0f,axisMove.y) * moveForce); - rb.LinearVelocity = new Vector3(axisMove.x * moveForce, rb.LinearVelocity.y, axisMove.y * moveForce); + rb.LinearVelocity += new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce) * Time.DeltaTimeF; if (isMoveKeyPress) {