STEAM GROUP
๐˜ฝ๐™๐™ค๐™ฅ ๐™ˆ๐™–๐™ฉ๐™๐™š๐™ข๐™–๐™ฉ๐™ž๐™˜๐™จ ๐˜‰๐˜ฉ๐˜ฐ๐˜ฑ
STEAM GROUP
๐˜ฝ๐™๐™ค๐™ฅ ๐™ˆ๐™–๐™ฉ๐™๐™š๐™ข๐™–๐™ฉ๐™ž๐™˜๐™จ ๐˜‰๐˜ฉ๐˜ฐ๐˜ฑ
0
IN-GAME
2
ONLINE
Founded
13 November, 2019
Location
Japan 
ABOUT ๐˜ฝ๐™๐™ค๐™ฅ ๐™ˆ๐™–๐™ฉ๐™๐™š๐™ข๐™–๐™ฉ๐™ž๐™˜๐™จ

๐˜ฝ๐™๐™ค๐™ฅุœ ๐™ˆ๐™–๐™ฉ๐™๐™š๐™ข๐™–๐™ฉ๐™ž๐™˜๐™จ

Vc = The current velocity before any calculations
Vw = The direction that the player wants to move in (the so-called wish direction).
Vp = Vc projected onto Vw. Keep in mind that we are only considering magnitude in this calculation, so the direction of the projection doesn't matter.
Va = The acceleration to be added to Vp. The magnitude of this acceleration is server-defined.
Vmax = The server-defined maximum velocity. If Vp + Va exceeds this, then Va is truncated.




// accelDir: normalized direction that the player has requested to move (taking into account the movement keys and look direction)
// prevVelocity: The current velocity of the player, before any additional calculations
// accelerate: The server-defined player acceleration value
// max_velocity: The server-defined maximum player velocity (this is not strictly adhered to due to strafejumping)
private Vector3 Accelerate(Vector3 accelDir, Vector3 prevVelocity, float accelerate, float max_velocity)
{
float projVel = Vector3.Dot(prevVelocity, accelDir); // Vector projection of Current velocity onto accelDir.
float accelVel = accelerate * Time.fixedDeltaTime; // Accelerated velocity in direction of movment

// If necessary, truncate the accelerated velocity so the vector projection does not exceed max_velocity
if(projVel + accelVel > max_velocity)
accelVel = max_velocity - projVel;

return prevVelocity + accelDir * accelVel;
}

private Vector3 MoveGround(Vector3 accelDir, Vector3 prevVelocity)
{
// Apply Friction
float speed = prevVelocity.magnitude;
if (speed != 0) // To avoid divide by zero errors
{
float drop = speed * friction * Time.fixedDeltaTime;
prevVelocity *= Mathf.Max(speed - drop, 0) / speed; // Scale the velocity based on friction.
}

// ground_accelerate and max_velocity_ground are server-defined movement variables
return Accelerate(accelDir, prevVelocity, ground_accelerate, max_velocity_ground);
}

private Vector3 MoveAir(Vector3 accelDir, Vector3 prevVelocity)
{
// air_accelerate and max_velocity_air are server-defined movement variables
return Accelerate(accelDir, prevVelocity, air_accelerate, max_velocity_air);
}
POPULAR DISCUSSIONS
VIEW ALL (6)
GROUP MEMBERS
Administrators
Members
0
IN-GAME
2
ONLINE
0 IN CHAT
Enter chat room
Founded
13 November, 2019
Location
Japan