Is predicted physics enabled by default in 1.0? It’s not quite clear to me from the docs if there’s something I need to do.
Or perhaps I’m doing something wrong. I’m trying to fire some projectiles that have a physics body+shape and are owner predicted. When fired on the client, the projectile seems to not move until it’s fired on the server (I put some simple logging in and increased simulated RTT to determine this), at which point it snaps forward on the client to where it is on the server.
Any ideas what might be wrong here? I can provide more info if needed.
In order to to use physics simulation for predicted ghosts you must enable it by creating a singleton with the PredictedPhysicsConfig component. The singleton must exist on both the client and server with compatible values (same simulation frequency). The component lets you specify the physics tick rate as a multiple of the NetCode simulation tick rate, so you can run for example a 60Hz game simulation with 120Hz physics simulation.
What do you mean by not predicted physics in this case, what are you trying to do?
The way it works in 1.0 is that any predicted ghost with non-static physics will predict the physics simulation of that ghost. Any interpolated ghost with physics will update on the server but will be kinematic on the client since the client cannot move it. So the way to enable not-predicted physics is to not have any predicted ghosts with physics simulation.
If you do not have any predicted ghosts with physics velocity the physics group will not run for re-simulated ticks on the server so it doesn’t give you a big performance hit.
If you want some client only physics for visual effect (debris, particles etc which does not exist on the server) you need to setup a secondary physics world to simulate them since they cannot affect the physics simulation of ghosts.
This was actually the only setup that really worked correctly in older version too, which is why we made it the default.
They will run in the prediction group. But unless you have predicted ghosts with physics they will not run for every prediction tick on the client. They will just run the same number of times they would if they were not in the prediction group - which depends on the fixed rate.
It should affect only replicated (kinematic or not) ghosts. For non-replicated entities, the PhysicsVelocity is reset to zero only if PhysicsMassOverride.SetVelocityToZero is set.
For Replicated Kinematic Character in particular, that may cause some little “jittery/less smooth” motion as you described.
Sorry for the slow reply. I went on holidays and came back to my house being flooded by a river…
So I’ve been busy ^ and I haven’t tested enough to say for certain this is how it works, but I believe my problem stems from the fact I only use interpolated ghosts and no prediction.
In this case I can’t see why my client only physics objects need to exist in a secondary physics world instead of all existing in the same world. I don’t want the overhead of running 2 physics simulations for no reason - I was already having problems with physics.
You only need a client-only physics “world” if you need to have some physics that run only on the client and you don’t need that to rollback or predicted in any way.
Otherwise, there is no reason for two indices. The use of interpolation or extrapolation does not requires any extra world.
how to collide with different world (Physics Predict World And Client Only World), In document, say use PhysicsProxyGhostDriver component, but I dont see this componet in network package。
We a re updating the docs. The logic is changed a little bit.
You just need to add a CustomPhysicsProxyAuthoring authoring to ghost prefab. That will create a “proxy” physics object in the client-only world that will collided with the client-only physics objects.