Increasing performance with thousands of moving parts

So, I’m working on a space game where the pretty big spaceship blows up. It’s epic. Even better, with minimal work, I’ve got it running relatively smoothly and it works decently well on my (average) computer and iPhone 8.

But I want it to be better. Right now, there can be noticeable drops in framerate and players’ characters always seem to replicate slowly. This is understandable as there are hundreds (maybe even thousands) of flying parts floating around as the ship explodes.

I have optimized the particle system and the actual amount of destruction being done at once, but what can I do to optimize the physics happening? I’ve considered these but they all have caveats:

  • StreamingEnabled —I don’t like how streaming forcibly hides things in the distance and doesn’t give me control over which parts to replicate to the client.

  • Anchor parts after some time —This will probably solve most of my issues, but it ruins the immersion. I want pieces of my ship floating around in deep space :frowning:

Does anyone have any other solutions to this problem? Thanks.

2 Likes

Frankly, without that space partitioning or ignoring the caveats of potential solutions, you aren’t going to have much luck with improving performance for many moving parts. The objective is not to let the physics engine simulate where not necessary.

For me personally, I’d just have some lousy excuse like “the material of this ship’s parts disintegrate after n seconds” or something as an excuse to destroy parts later. It’s going to end up becoming necessary either way: what happens when you have thousands of exploded ship parts floating in space? That’s some major physics simulation going on.

1 Like

Depending on how your map layout is, I suggest a method in which you place and remove parts through a script to life some weight off the client’s GPU. But in order to implement this, I would need more background knowledge on your games map layout and structure.

You can probably fake it, create a group that has an already made animation/effect created (basically a cache of some sort)

When you’re ready, summon it to the proper locations/places you want it to happen, it’ll simulate the parts blasting out effect with the same thing, then make the parts immediately disappear after going out a certain distance or duration.

2 Likes

Ummm… Yeah, that’s not going to be possible. I can’t make an animation for every single possible explosion.

are the explosions happening on the server?

You could add a random chance (like 10-20%) to destroy some of the parts upon the initial explosion. I think this would probably relieve the physics engine to some degree, about 100 to 200 parts less if you’re at a thousand. I still think it would look awesome even with a few less parts. :wink:

As others have mentioned, you potentially could also have the remaining parts fade out or shrink over time until you can destroy them without notice. That or remove them once they’re far enough away from all of the players.

1 Like

I hope that your doing this on the client, if your not, for big things like this you should be putting this on the client. If you already have it on the client, the only solution I think of right now is procedural rendering the parts being exploded. One way this could be a achieved is rays being casted all of the screen, but now you have a ray problem.

I really like this, you can make your own explosion effect and generate a region3 and find the parts touching the region3. In no way this is a solution, just trying to give some possible solutions to think about. Good luck!

This would be just as bad on the client, and this needs to be server side so everyone sees it.

@Crazycat4360 I’m already deleting the small parts. I might do this. :slight_smile:

1 Like

Yeah, you should be doing the initial math on the server, and having the actual effect being ran on the client. I remember this thread where someone had a problem of wanting to render a whole bunch of NPC animations, but since they were doing it on the server, they would be slow and laggy. Once they put it on the client, it would be fine. I have to look for this for context.

That’s completely different. Those are NPC animations and aren’t important to gameplay. This is a core mechanic of my game and cannot be client-sided. Even if it were, that’s not going to be as simple as “doing initial math on the server”— that’s creating an entirely new physics engine.

And again, it doesn’t matter because I’ve already tested on the client and still run into physics issues. :confused:

1 Like

Yeah, but I remember it working pretty smoothly… The problem was connection lag in that case.

Why can’t it be client sided? Usually all my visual aspects are done on the client. I only really use the server for my projects is client verification, secure payment transactions, and sensitive math.

I mean it depends the way you approach it, you could be sending tween positions to the client, or where the parts should be in the next 5 seconds.

This might be a roblox limitation or you implemented it wrong. I don’t think your going to be able to achieve this on an iPhone or any mobile phone without seemlessly taking parts out.

Anyway, this was just how I would look at the problem, didn’t test it or anything, however I’m curious… Best of luck!

I have everything visual in this game already on the client. I agree it’s a great way to get things looking smooth, but unfortunately won’t work here.

It would be a huuuge headache, if not impossible to do that with Roblox physical objects, and not to mention, the debris is practically guaranteed to be out of sync between clients. This is the core aspect of my game. Players can explore the debris, fly around it, etc. Plus I need the server to handle the physical objects for other things.

It’s easier to say that than it is done. Again, I would have to make my own custom physics engine to accomplish this. That is well beyond the scope of this project.

Yes. I’m looking for some ways to get around the Roblox limitations, because my way isn’t good enough.

I appreciate the help, but unfortunately moving everything to the client won’t work here.

You could make it so that after an explosion the debris will eventually come to a stop. Once they are done moving you can anchor them and the physics will no longer need to worry about them. Then, you could use Region3 to unanchor the parts that are near enough to the clients to where they could interact with them. If a player can not interact with a part, then don’t make physics do the work on it.

This is just my idea in case it might help you come up with a solution.

2 Likes