Explosions and Their Physics - How do I run on the Client?

I am working on a new game with @jdevved. We did our first playtest yesterday, and it went pretty swell!

A somewhat big issue that was encountered, however, was with explosions and the physics of exploded parts. In our game, 75% of the map is destroyable, and by the end of games/rounds, the entire map will be leveled with tons of pieces of the buildings and towers strewn all over the place, like seen in the videos below.


For many players, they won’t have lag, but after a few rounds, depending on the map, a lot of users in our playtest complained that they were laggy and their framerates went down. One of them suggested that we should run physics of exploded parts on the client, to which I agreed - however, I have ran explosions on the client before in games, and it caused issues (granted it was a tycoon game were a lot could go wrong if people’s bases got blown up), and really haven’t ran explosions/physics of exploded parts on the client before.

This is a big gameplay element we have chose to go with, and it is something we do not want to get rid of - we don’t even want to have the map regen at intervals in the game, especially since the max time for games/rounds are only 15 minutes maximum, and likely will be far shorter when the score limit is reached in full(er) servers. Regening would also take away from the immersion of the destruction and chaos we want for gameplay.

How would I optimize explosions and physics for parts hit/being impacted by explosions? I was thinking of just including in the explosion scripts, when a part is broken/impulsed by an explosion, to have that part’s NetworkOwner set to the player who exploded said part with a rocket launcher, but I wonder if that would cause consistency issues that other players would see, or cause issues when the maps are deleted/cleaned up at the end of each round.

2 Likes

You’re certain that all of these parts are being destroyed though right? And no memory leaks are happening?

3 Likes

You could anchor objects after they stop moving. That’ll reduce your lag significantly. Walls that are laying flat on the ground don’t need physics

3 Likes

Correct. After every round, a model called “Map” is destroyed and then regenerated, and all destroyed parts are parented inside of this.

As for memory leaks, the client memory usage is always at 1000-1200MB of usage or less, even with this lag. I can tell this is a physics issue and less of a memory issue IMO due to how slow the rocket from a rocket launcher, another physic(al) part, moves while stuff on the map gets destroyed.

1 Like

Not something we want to do. We want the parts of the map to always be blowup-able, even if they are remnants of a formerly standing building. Adds to the chaos.

1 Like

Yes, but you can always unanchor an object if it gets hit by something. I’m just saying that you shouldn’t waste resources on objects nowhere near any player

1 Like