What is the best way you guys have found to put a bunch of physics objects in a game?

I am currently making a game that will make use of hundreds of objects with physics that players can push around on one map. This of course comes with the caveat of heavy optimizations needed. I am a new developer and was wondering if there is anything that has already been done that I may be able to take advantage of.

1 Like

Hey! I love seeing new developers on the dev forum, great to have you here!!

I would recommend you trying out the different physicall attachments on your own!! In order to access them you will have to go to the Modelling section go almost all the way on the right and there you will find a button that says create.
At first you will see a bunch of connectors. They connect one part with another. But right under you will find attachments that can add physics if you put them on a part like “VectorForce”.

Good luck on your journey as developer!!!

1 Like

Thanks for the good wishes! I am however well aware of the physics constraints and have a ‘solid enough’ idea what all of them do. In fact for the objects in question I use welds quite commonly. Do you know anything about optimization and physics constraints? I’m aware having a bunch of constraints adds a lot of stress to the game so any work arounds or shortcuts and stuff like that are much appreciated.

Some simple things you can do is to reduce the part count (and therefore the number of constraints required). Creating unions (or meshes) is one way to do this, just bearing in mind the design drawbacks.
Turning off CanTouch where possible, and using DebrisService to clean up unused parts should also reduce your physics load.
I’m not super knowledgeable in this area but hope it helps!

2 Likes

A good thing to think about is collision fidelity. For example, you may have a wooden box, but the player doesn’t need to touch every nook and cranny. Therefore by setting collision fidelity to Box then the player only interacts with 4 faces instead of however many your box actually has.

Another thing is being frugal with when the player actually needs to interact with items. If it’s left alone and the player isn’t touching or even seeing it, it may take some memory regardless, so anchoring it and even setting cancollide off could reduce a lot of lag, and when the items detect interaction to unanchor it again.

Turning off cancollide for objects that don’t need to be collided may also give a bump up in performance. With a game heavily involved in physics, I would find any method I can to optimise it. Sometimes you could even animate certain objects to mimic the look of it being in a physical environment to further optimise things.

Hope this helped.

1 Like

Don’t unions themselves cause optimization issues? I think meshes should hold fine from my experience.

This is why I caveated my advice (physics optimisation isn’t something I’ve had to worry too much about in my games).
Edit: I think I’ve walked into a rabbit hole suggesting unions! Yes they cause their own issues depending on the result of creating the union, so for simple shapes the engine might find a micro optimisation, but this is only for the graphical rendering. In terms of physics, it would depend on the collision box as @Cafran has explained.

1 Like