camp vel
This commit is contained in:
parent
c572bb0f58
commit
48f01e4164
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue