Recommended way of making game objects gui-like

Hey everyone, I’m working on an adventure game and currently want to implement an inventory system. Because I want to use go’s instead of gui elements (to keep mouse over and touch logic consistent with the rest of the game), I have a few questions about recommended/more performant ways to approach it:

  • Which way of making sure they are drawn in the front is more idiomatic/better performance: ordering by z coordinate or creating materials and updating render script for those materials to be drawn on top?
  • Follow-up question to that, is it more performant/idiomatic to create/destroy inventory objects or just disable and ignore until needed again (think about inventory being opened every once in a while)?

Thanks in advance for any advice!

2 Likes

@Alesis Hi! I can just tell about my experience. I don’t use gui (probably just because I am lazy and I don’t want to learn other API than go :slight_smile: ).

  1. If your inventory does not interact with other game elements then I would create a different material tag. Probably you want this material to be drawn also after the game particles. So maybe you will need also a new particle tag if you need particle effects for the inventory. You see, this approach may soon lead to the creation of many different tags… try to keep them at minimum. Each tag has its draw_call(s), but I would still prefer some more drawcalls but a clearer design than z ordering (clearer at least for me!).

  2. Only collection creation may need some computation time. Since I may aspect that items in your inventory are rarely added / removed I would create only the ones that are really needed and not cache them.

I hope that what I wrote is clear. Again, just my idea. Probably others will give you different hints.

Ciao!

3 Likes

Thanks for the tips!

Not sure I understand what you mean - I was considering whether it makes sense to use a factory to generate the items every time the inventory is open or just disable and re-enable them. I feel that generating them might be a bad idea performance wise, so maybe disabling the go’s is a better way to do it.

Surely my fault, not so clear…

I would definitely advice NOT to generate them each time the inventory is open!