Hello ,
I have an issue with the new physics replication implementation in 4.20 and 4.20.1. It seems the new error accumulation does not work as intended. Also, it seems that primitive component “dormancy/sleep” is not replicated correctly.
There are a lot of comments and TODOs in the new PhysicsReplication.ccp module. These out-commented lines caught my attention: PhysicsReplication.cpp#L346. Don’t really know what to look for here but this module does not look as production-ready as most other modules in the engine.
video: - YouTube
The pop at ~0.09 seems to be causing some desync that results in a lot of error accumulating
project: phys420
Same behavior has been seen at ~4 different machines and was not present in 4.19.
Edit: perhaps someone has found a workaround for this? This seems to be the new way of configuring the physics replication:
[/Script/Engine.PhysicsSettings]
PhysicErrorCorrection=(PingExtrapolation=0.100000,
ErrorPerLinearDifference=1.000000,
ErrorPerAngularDifference=1.000000,
MaxRestoredStateError=1.000000,
PositionLerp=0.000000,
AngleLerp=0.400000,
LinearVelocityCoefficient=100.000000,
AngularVelocityCoefficient=10.000000,
ErrorAccumulationSeconds=0.500000,
ErrorAccumulationDistanceSq=15.000000,
ErrorAccumulationSimilarity=100.000000)
As opposed to:
[/Script/Engine.Engine]
PhysicErrorCorrection=(LinearDeltaThresholdSq=5.000000,
LinearInterpAlpha=0.200000,
LinearRecipFixTime=1.000000,
AngularDeltaThreshold=0.628319,
AngularInterpAlpha=0.100000,
AngularRecipFixTime=1.000000,
BodySpeedThresholdSq=0.200000)
Has anyone found a way to tweak the new values to remove the accumulating errors?
Edit2:
Found a workaround after looking at the code a bit more. It’s hopefully in line with how the devs meant this to be used. However, it should be said, this workaround will only slightly help to re-stabilize the simulation. I think the new “physics manager” approach is a step in a direction where it’s possible to implement things like prediction-correction (as in e.g. Rocket League or Overwatch), but none of that is currently in the engine:
The new physicsreplication module has that config set mentioned above. However, it’s not used by the engine since there is a set of cvars overriding them if not configured to be < 0.0. In our case we want to change the PositionLerp
setting to help things stabilize. PositionLerp
defaults to exactly 0.0
, which means it will override settings in the config. This means we need to either:
[/Script/Engine.PhysicsSettings]
PhysicErrorCorrection=( ... ,PositionLerp=0.020000, ... )
[SystemSettings]
p.PositionLerp=-1 ;; <-- something smaller than 0
or just:
[SystemSettings]
p.PositionLerp=0.02
Took me a while to figure that out. I think perhaps a general rule to prevent these kind of issues being time sinks would be to avoid having cascading settings like this in the engine. Or, at least, be very explicit (as in documentation) about it.