mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
local dampening
This commit is contained in:
parent
e88f88f4c1
commit
8cf073fe5b
@ -41,6 +41,10 @@ public class ForecastRigidbody : NetworkBehaviour
|
||||
ForecastState state = ForecastState.FOLLOWING; // follow until the player interacts
|
||||
double predictionStartTime;
|
||||
|
||||
[Header("Dampening")]
|
||||
[Tooltip("Locally applied force is slowed down a bit compared to the server force, to make catch up more smooth.")]
|
||||
[Range(0.05f, 1)] public float localForceDampening = 0.2f; // never 0 to ensure blending ALWAYS catches up instead of same speed
|
||||
|
||||
// motion smoothing happen on-demand, because it requires moving physics components to another GameObject.
|
||||
// this only starts at a given velocity and ends when stopped moving.
|
||||
// to avoid constant on/off/on effects, it also stays on for a minimum time.
|
||||
@ -124,6 +128,12 @@ public override void OnStartClient()
|
||||
// client prediction API
|
||||
public void AddPredictedForce(Vector3 force, ForceMode mode)
|
||||
{
|
||||
// apply local force dampening.
|
||||
// client applies a bit less force than the server, so that
|
||||
// catching up to blending state will be easier.
|
||||
// for example: dampening = 0.1 means subtract 10% force
|
||||
force *= (1 - localForceDampening);
|
||||
|
||||
// explicitly start predicting physics
|
||||
BeginPredicting();
|
||||
predictedRigidbody.AddForce(force, mode);
|
||||
|
Loading…
Reference in New Issue
Block a user