Turn off physics for a collection?

My game consists of one “main” gameplay screen but multiple menu screens. I’m using collection proxies for the menu screens, but I recently encountered this error:

ERROR:PHYSICS: Physics world buffer full, world could not be created.

This was a good warning for me, because I don’t need physics on any of those menu screens and I’m hoping if I disable it on those screens it will increase performance. Is there a way to disable a collection (or world) from using the physics engine?

1 Like

No, there is no way to disable physics on individual collections. It would only have a very marginal impact on performance anyway. You’d save some runtime memory but that’s about it. Are you having performance issues?

1 Like

I am having minor performance issues switching collections, but you’ve already addressed them in this thread. I’ve tried loading async which has helped, but I’m still noticing variable load times in collections. In other words, sometimes it’s almost seamless (100-200ms between switching), but sometimes it takes 2000-4000ms which is very noticeable to a user. Thanks for your help anyway!

2 Likes

Is it always the same sequence of events that results in 2000 vs 200ms or is it totally random? In the case where it takes 2000ms it could be because none of the resources required are loaded, while in the 200ms case it could be that some of the resources have already been loaded since they perhaps were in use by another collection.

It seems pretty random. I’ve changed my code so that once it’s loaded it’s cached and renabled, so obviously that’s faster, but on first-time app load, some collections’ initial load is very fast, while other times it seems to take a few seconds.

Perhaps there’s a profiling tool that can help me track down what’s causing the slowdown?

Is this on a mobile device or on your local machine? If it’s on your local machine then what OS are you using? Perhaps there’s some disk issues or an over-zealous anti-virus?

@therondevelopment If you use the web profiler, then you can capture several frames, and you’ll see the spikes in frame time. From there you should be able to pin point more exactly what system is causing this.

3 Likes

Can this be used with a production app, or only in development mode? I.e. can I use this for an iPhone running a test flight version of my app from the app store?

The webprofiler is available in bundles where the release checkbox hasn’t been ticked (and yes you can have such a build in production if you want to).

I also bumped into this limit, which causes this crash:

When I upped the limit, I noticed this message:

It would be nice with a “no physics” flag for each collection.

1 Like

Yeah a crash is not very user friendly.

We have a fix for this in the Defold 1.2.168 BETA

Yes, we’ve discussed this and have it in our backlog.

1 Like

For anyone who finds this article while searching the Internet: You can currently do what this other article suggests.

Removing physics altogether doesn’t seem like the OP was after.
OP was asking how to turn it off for a single collection.

Nowadays, there will be no physics world created if there are no physics objects in the collection.
So, no action required for e.g. gui collections.

1 Like

I don’t have any physical objects created (I’m only working on UIs), and I’ve hit the limit of 4 physics worlds because when I create a proxy collection, it seems it is get created automatically. I’m not sure if it’s due to a bug.

Then I think you have a case where we don’t know beforehand if you’ll use physics.
E.g. if you do dynamic setting of prototypes for factories (Factory component manual)
(@AGulev do you remember any other rules we use for this?)

For now, we create worlds, but without components in it: https://github.com/defold/defold/blob/8f9d2eebeb41165ea89e902828d5025621cfd75c/engine/gameobject/src/gameobject/gameobject.cpp#L354-L374

I don’t remember for 100% why it’s so (it was like 3 years ago), but there was some reason for it :man_shrugging:

2 Likes

No, I haven’t used factory for anything yet either. Just game objects, GUI (text and box), sound, and collection proxy.

Probably to avoid having to constantly check if it exists or not, or because of the timing and pause issues.

The proxy component is intended to change screens/levels, which is why it creates physics worlds. Is there a reason you’re not setting collections with factories?