|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// public float WalkSmoothing = 3;
|
|
|
|
// private float agentVel;
|
|
|
|
public void RunOnGround(Vector3 dir) |
|
|
|
{ |
|
|
|
if (dir == Vector3.zero) |
|
|
|
|
|
|
{ |
|
|
|
var vel = rb.velocity.magnitude; |
|
|
|
float adjustedSpeed = Mathf.Clamp(agentRunSpeed - vel, 0, agentTerminalVel); |
|
|
|
// float adjustedSpeed = Mathf.MoveTowards(vel, agentRunSpeed, WalkSmoothing);
|
|
|
|
// float adjustedSpeed = Mathf.SmoothDamp(vel, agentRunSpeed, ref agentVel, WalkSmoothing, agentTerminalVel);
|
|
|
|
|
|
|
|
// rb.AddForce(dir.normalized * adjustedSpeed, runningForceMode);
|
|
|
|
rb.AddForce(dir * adjustedSpeed, runningForceMode); |
|
|
|
if (AnimateBodyMesh) |
|
|
|