add to vel instead of setting it

This commit is contained in:
Glence 2022-11-16 22:28:08 +08:00
parent 3f3770f74f
commit df9cb11446
1 changed files with 2 additions and 7 deletions

View File

@ -130,7 +130,7 @@ public class PlayerController : Script
GotCaught(); GotCaught();
//Debug.Log($"{currentState}"); //Debug.Log($"{currentState}");
//Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}"); //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()); //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(); //Rotation();
MoveKey(); MoveKey();
//to be change
if (rb)
rb.AddForce(new Vector3(-rb.GetForce().x, -rb.GetForce().y, -rb.GetForce().z));
Move(); Move();
Sprint(); Sprint();
Jump(); Jump();
@ -224,7 +219,7 @@ public class PlayerController : Script
if (rb != null) if (rb != null)
{ {
//rb.AddForce(new Vector3(axisMove.x, 0.0f,axisMove.y) * moveForce); //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) if (isMoveKeyPress)
{ {