PlayerController and PickAndThrow #167

Merged
glencelow merged 21 commits from PlayerController into main 2022-11-02 17:40:51 +08:00
1 changed files with 13 additions and 6 deletions
Showing only changes of commit 48f01e4164 - Show all commits

View File

@ -82,21 +82,28 @@ public class PlayerController : Script
if (rb != null && currentState == RaccoonStates.WALKING)
{
if (rb.LinearVelocity.x <= maxMoveVel)
rb.AddForce(new Vector3(moveForce * xAxisMove * (float)Time.DeltaTime, 0.0f, 0.0f));
if (rb.LinearVelocity.x <= maxMoveVel || rb.LinearVelocity.x >= -maxMoveVel)
rb.AddForce(new Vector3(moveForce * xAxisMove, 0.0f, 0.0f));
else
{
Vector3 v = rb.LinearVelocity;
v.x = maxMoveVel;
if(v.x >= 0)
v.x = maxMoveVel;
else
v.x = -maxMoveVel;
rb.LinearVelocity = v;
}
if (rb.LinearVelocity.z <= maxMoveVel)
rb.AddForce(new Vector3(0.0f, 0.0f, moveForce * zAxisMove * (float)Time.DeltaTime));
if (rb.LinearVelocity.z <= maxMoveVel || rb.LinearVelocity.z >= -maxMoveVel)
rb.AddForce(new Vector3(0.0f, 0.0f, moveForce * zAxisMove ));
else
{
Vector3 v = rb.LinearVelocity;
v.z = maxMoveVel;
if (v.z >= 0)
v.z = maxMoveVel;
else
v.z = -maxMoveVel;
rb.LinearVelocity = v;
}
}