mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
perf: PredictedRigidbody UpdateGhosting: only every few frames
This commit is contained in:
parent
be0efc9fb6
commit
0fc6688cea
@ -86,6 +86,9 @@ public class PredictedRigidbody : NetworkBehaviour
|
||||
public Material localGhostMaterial;
|
||||
public Material remoteGhostMaterial;
|
||||
|
||||
[Tooltip("Performance optimization: only create/destroy ghosts every n-th frame is enough.")]
|
||||
public int checkGhostsEveryNthFrame = 4;
|
||||
|
||||
[Tooltip("How fast to interpolate to the target position, relative to how far we are away from it.\nHigher value will be more jitter but sharper moves, lower value will be less jitter but a little too smooth / rounded moves.")]
|
||||
public float positionInterpolationSpeed = 15; // 10 is a little too low for billiards at least
|
||||
public float rotationInterpolationSpeed = 10;
|
||||
@ -386,6 +389,10 @@ protected virtual bool IsMoving() =>
|
||||
|
||||
void UpdateGhosting()
|
||||
{
|
||||
// perf: enough to check ghosts every few frames.
|
||||
// PredictionBenchmark: only checking every 4th frame: 585 => 600 FPS
|
||||
if (Time.frameCount % checkGhostsEveryNthFrame != 0) return;
|
||||
|
||||
// client only uses ghosts on demand while interacting.
|
||||
// this way 1000 GameObjects don't need +1000 Ghost GameObjects all the time!
|
||||
|
||||
|
@ -17,3 +17,4 @@ Not Predicted: 1000 FPS Client, 2500 FPS Server
|
||||
Predicted:
|
||||
2024-03-13: 500 FPS Client, 1700 FPS Server
|
||||
2024-03-13: 580 FPS Client, 1700 FPS Server // micro optimizations
|
||||
2024-03-14: 590 FPS Client, 1700 FPS Server // UpdateGhosting() every 4th frame
|
||||
|
Loading…
Reference in New Issue
Block a user