Defold-input and collection proxies

Hey everyone, I’m trying to use the cursor from defold-input to have mouse-over events on an inventory and anything else in the game scene. For the inventory and the different game levels I was planning on using collection proxies.

Because defold-input cursor relies on collisionobjects to detect mouse-over and collisionobjects rely on physics, this doesn’t seem to work with collection proxies since they spawn separate worlds with separate physics simulations. So my question is whether there is a way to make it work? Alternatively, if anyone has ideas for a better way to do mouse-over while still using collection proxies I’d love to hear it!

Thanks!

Are you going to interact with the inventory at the same time as the game level?
If not, then I think it’s ok for the inventory to be in a separate collection, with a separate physics world. Or am I perhaps missing something?

I wouldn’t be interacting at the same time, but the collisionobject associated with the cursor would live in a different world, or does it mean I need to create a separate cursor for each collection and disable it when I enable different proxies (seems very tedious)?

Ah, yes, you’d have to have a separate cursor object in the inventory collection.

I haven’t tried it yet, but I wonder if the transition would be smooth between cursors. I think the most annoying part of this is if I have multiple collection proxies active at the same time (as it would be in the inventory case), I’d need to disable one of the cursors (not to risk some update mismatch and rendering 2 cursors at the same time 1 pixel apart) and re-enable once the inventory is closed.

I’ll try playing around with it to see if the transitions of the cursor feel smooth or not (very objective measure, I know).

A quick side-question to people who’ve done more things and have more experience: how many simultaneous collection proxies should I limit myself to not to impact performance too much (the game itself won’t spawn too many objects (< 100) and physics are mostly used for mouse collision detection only).

Multiple cursor objects will solve the problem, but you may run into problems when more than one cursor needs to be active at the same time.

You should keep this number fairly low (I’m guessing here but perhaps less than 10). Each collection proxy will have its own physics world and each of these use a bit of memory

In my minds eye I don’t think I’ll need more than one cursor at a time. If I do, I’ll need to completely rethink the whole cursor thing, since this is the only way I can think of of how to do mouse-over events for now.

2 Likes

So I’ve toyed around a little bit and it seems that trying to disable the cursor in the background proxy while I enable the inventory proxy does produce some flicker (seems like the proxy enable and the first draw calls don’t happen in the same frame). So I might have to keep the background cursor enabled, just disable the collisionobject and hope that the drawing of the 2 cursors never goes out of sync :smiley:

Any other ideas are very welcome!