GRUPA STEAM
𝘽𝙝𝙤𝙥 𝙈𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙨 𝘉𝘩𝘰𝘱
GRUPA STEAM
𝘽𝙝𝙤𝙥 𝙈𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙨 𝘉𝘩𝘰𝘱
1
W GRZE
2
ONLINE
Założona
13 listopada 2019
Położenie
Japan 
O 𝘽𝙝𝙤𝙥 𝙈𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙨

𝘽𝙝𝙤𝙥؜ 𝙈𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙨

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);
}
POPULARNE DYSKUSJE
CZŁONKOWIE GRUPY
Administratorzy
Członkowie
1
W GRZE
2
ONLINE
0 NA CZACIE
Wejdź do pokoju
Założona
13 listopada 2019
Położenie
Japan