Closed Travistyse closed 3 months ago
I've pushed a few fixes to the project and a fix to the plugin to hopefully resolve the first issue. I was able to reproduce it locally with 5.3 and the latest commit fixed it. I tend not to really update the example project unless I know I've made breaking changes, so apologies for that.
The crash you're getting when compiling the blueprint is likely because you're hitting the assert in UClientPredictionComponent::InitializeComponent()
that checks that a physics model has been created. You need to use the plugin from C++ at the moment, and I don't really have plans to change that. You definitely could implement the model in blueprints, but you would need a bit of C++ to forward the physics model calls and then also wrap FPhysicsContext
.
This plugin is meant to do what you're describing. I'm personally using it make a multiplayer tank game. It's heavily inspired by the NetworkPrediction plugin that comes with the engine which is a lot more comprehensive, but never really worked right in my experience. The example project is a ball can be rolled around / jump by applying forces with wasd and space.
Basically you need 5 things:
FBallPawnState
) with a NetSerialize
, ShouldReconcile
and Interpolate
function. Position, rotation and velocities are all handled for you, so they don't need to be in your state. FBallPawnInputPacket
) with a NetSerialize
function.ETestEvents
) -- the interpretation of what these are is kind of up to you, but they are dispatched during the physics thread simulation and "happen" during the DispatchEventDelegate
callback on the game thread.ClientPrediction::FPhysicsModel
that implements the unimplemented methods (FBallPawnModel
). There are a couple other virtual methods in there you can override as well, but those are optional. The main methods on this are the pre-physics and post-physics. Forces can be applied in the pre-physics through the physics context, physics are run and then post tick is called so that you can update the output state with the results of the physics tick. The states get sent to simulated proxies and interpolated and are what are used to reconcile against the authority on the autonomous proxy. ABallPawn::PostRegisterAllComponents
). The delegate methods all have code comments that describe what their purpose is, but really only ProduceInputDelegate
and FinalizeDelegate
are "required". Hopefully that's reasonably comprehensive, and the example of course contains everything you need to get started, but feel free to ask any other questions.
Going to close this since the 5.4 update changed basically everything.
Downloaded the example, inserted the client prediction plugin, compiled for 5.3 just fine but I'm seeing the following issues:
No replication is occurring for the ball between any clients or the server - if not for adding a print string and having the messages be replicated, I'm not sure that there's any amount of replication occurring. Spawning a particle effect didn't do anything, either - what is happening is that the ball pawns spawn in, can be seen on the server, and then the server no longer sees them and they never see each other.
The plugin's component is a crash-a-holic. If you add it to anything it crashes. Honestly this project crashed after doing basically anything, but would work after a few crashes usually - I can nonetheless not create an actor blueprint with the component on it - at compile time it crashes.
I'd like to try using this plugin because I'd like to have deterministic physics for replays and relatively network stable physics based gameplay but I'm on 5.3 and don't know if the problem is that this project just didn't upgrade properly and using the plugin would work but the example is the only documentation I have for this plugin so I'm not sure what to do to enable what I'm trying to achieve, nor do I even know which systems are affected by the plugin and how to use it exactly?
I very very much appreciate what you've made but am struggling to use it at the moment - this is intended to work with forces, launching, and physics simulation, right? Does this do anything for launching Characters or adding force to them? Sorry for all of the questions - I'm very excited and hopeful given that a deterministic physics engine could enable entire elements of gameplay that weren't previously possible for me afaik.