Advertisement

Vehicles hitting characters - prediction problems

Started by May 14, 2023 01:52 PM
2 comments, last by BigWall 1 year, 6 months ago

Hi everyone! I once more seek your help!

For the start, here is the topic about my vehicles networking model for context: Topic

So, all of my vehicles are based on PhysX engine, however I don't use their vehicles model, I use my own physics by pushing boxes with forces etc. Results are very deterministic and use fixed time step simulation with state machines. My vehicles model is based on Rocket League mostly, so I predict all of the vehicles local, remotes, everything. Which means that all the vehicles we observer are in "Current Time" from our perspective. Usually prediction is close enough, so there is not that many rollbacks etc. We have done a lot of playtests, with a lot of people, and they were very successful.

However... our characters are not predicted. I found it extremely difficult to predict characters, because of their fast rotation and acceleration, they are nowhere near as easy to predict as vehicles are. So we only predict local character. Remote characters are always viewed from a few milliseconds from the past depending on latency. Effectively, we used fixed number of frames, that we are observing remote characters, so for example if you have 60ms ping, you will see remote clients from 65ms ago etc.

Our game offers leaving and entering vehicles with characters much like GTA etc.

Here is where the problems begin. Because we predict vehicles and we don't predict characters, it causes a lot of weird mismatches of the locations.

Basically our present version of the vehicle hits past version of the remote character, which is a huge problem, and causes characters to be forced inside vehicles and other weirds stuff. This is because our fixed time step simulation, before each next frame starts, forces all entities to their locations at that frame, so that they are all starting from the same state of the game at that point in time.

Too bad, characters are a few milliseconds from the past, so they were pretty much around our windshield this X amount of time ago, but our current vehicle is there.

It makes sense, these problems are something I completely understand, I understand they origin, but I can't seem to figure out a solution for it. Any kind of smoothing or interpolations won't work, because then we have character that is also pushed into vehicle, but slower, anything like that won't work here. Also, sweeping character capsule to check for collisions would be an option, but push out location is usually on the side of the vehicle or elsewhere, because it's the shortest path, and it's wrong comparing to the real location.

Does any of you have idea how other games such as GTA do stuff like this?

I came up with the solution to temporarily enable prediction for characters when they are hit, but that is very fragile system, and as soon as we mispredict the hit, it all falls apart. Characters go back and forth, and amount of time which we will be predicting for is also unknown.

Any ideas?

To avoid temporal artifacts like these, in general, you'll want to simulate all objects in the same timeframe. This either means predicting characters, or it means delaying all object kinds.

You can separately choose to display objects as-simulated, or display objects as-forward-predicted. I e, even if you simulate characters and vehicles 60 ms in the past, you may still display them on the screen in a position that is forward predicted based on their simulated position, orientation, velocity, and spin, optionally with some kind of collision depenetration for display purposes.

This is why the networking model of a game is so intrinsically tied to the gameplay feel of the game, and in turn tied deep into the simulation engine.

Given the setup you described, it's possible you could keep a trail of old character positions, and use those for car simulation, and then somehow propagate hits in the past forward to current character state – this will end up being similar to displaying characters forward-predicted from old positions, but only when they end up actually interacting with vehicles. However, if you still display them forward predicted, you may still end up rendering collisions that don't happen, if you go this way,

enum Bool { True, False, FileNotFound };
Advertisement

@Fury22 I understand the challenge you're facing with predicting character movements in your vehicle networking model. It seems that the current approach, which successfully predicts vehicles but not characters, is causing mismatches in locations and resulting in characters being forced inside vehicles and other unusual behaviors. You've explored options like smoothing, interpolation, and sweeping character capsules for collision detection, but these approaches have their limitations.

To address this issue, it could be beneficial to examine how other games, such as GTA, handle similar situations. Analyzing their approaches and techniques might provide insights and inspiration for improving your own system.

Additionally, you mentioned a temporary solution of enabling prediction for characters when they are hit. While this approach may have some drawbacks and fragility, it's worth exploring further. Perhaps you can fine-tune the prediction mechanism specifically for character hits to minimize mispredictions and inconsistencies.

This topic is closed to new replies.

Advertisement