mirror of
https://github.com/celisej567/UnitySourceMovement.git
synced 2026-09-21 20:08:38 +03:00
Update SurfController.cs
This commit is contained in:
@@ -85,22 +85,30 @@ namespace Fragsurf.Movement {
|
|||||||
speed = _surfer.moveData.velocity.magnitude;
|
speed = _surfer.moveData.velocity.magnitude;
|
||||||
_surfer.moveData.velocity.y = yVel;
|
_surfer.moveData.velocity.y = yVel;
|
||||||
|
|
||||||
float maxDistPerFrame = 0.05f;
|
if (_surfer.moveData.velocity.sqrMagnitude == 0f) {
|
||||||
Vector3 velocityThisFrame = _surfer.moveData.velocity * _deltaTime;
|
|
||||||
float velocityDist = velocityThisFrame.magnitude;
|
|
||||||
float velocityDistLeft = velocityDist;
|
|
||||||
float initialVel = velocityDistLeft;
|
|
||||||
while (velocityDistLeft > 0f) {
|
|
||||||
|
|
||||||
float amountThisLoop = Mathf.Min (maxDistPerFrame, velocityDistLeft);
|
// Do collisions while standing still
|
||||||
velocityDistLeft -= amountThisLoop;
|
SurfPhysics.ResolveCollisions (_surfer.collider, ref _surfer.moveData.origin, ref _surfer.moveData.velocity, _surfer.moveData.rigidbodyPushForce, 1f, _surfer.moveData.stepOffset, _surfer);
|
||||||
|
|
||||||
// increment origin
|
} else {
|
||||||
Vector3 velThisLoop = velocityThisFrame * (amountThisLoop / initialVel);
|
|
||||||
_surfer.moveData.origin += velThisLoop;
|
|
||||||
|
|
||||||
// don't penetrate walls
|
float maxDistPerFrame = 0.2f;
|
||||||
SurfPhysics.ResolveCollisions (_surfer.collider, ref _surfer.moveData.origin, ref _surfer.moveData.velocity, _surfer.moveData.rigidbodyPushForce, amountThisLoop / velocityDist, _surfer.moveData.useStepOffset ? _surfer.moveData.stepOffset : 0f, _surfer);
|
Vector3 velocityThisFrame = _surfer.moveData.velocity * _deltaTime;
|
||||||
|
float velocityDistLeft = velocityThisFrame.magnitude;
|
||||||
|
float initialVel = velocityDistLeft;
|
||||||
|
while (velocityDistLeft > 0f) {
|
||||||
|
|
||||||
|
float amountThisLoop = Mathf.Min (maxDistPerFrame, velocityDistLeft);
|
||||||
|
velocityDistLeft -= amountThisLoop;
|
||||||
|
|
||||||
|
// increment origin
|
||||||
|
Vector3 velThisLoop = velocityThisFrame * (amountThisLoop / initialVel);
|
||||||
|
_surfer.moveData.origin += velThisLoop;
|
||||||
|
|
||||||
|
// don't penetrate walls
|
||||||
|
SurfPhysics.ResolveCollisions (_surfer.collider, ref _surfer.moveData.origin, ref _surfer.moveData.velocity, _surfer.moveData.rigidbodyPushForce, amountThisLoop / initialVel, _surfer.moveData.stepOffset, _surfer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user