0 votes

I'm trying to figure out which would be the most efficient. I tried to look it up and found some stuff that was a little over my head, but boiled down to a script is lighter than a node in some cases. I'm in the planning stage of something akin to Cataclysm, and I'm trying to decide how I want to implement items. Be that in inventories or on the ground.

My current ideas are either using a Node2D with a small sprite as a child and a script holding the item info.

Or creating a complicated nested array that stores a tilemap coordinate, an array of items on that coordinate, each having either an array or dictionary containing the item information, and lastly the combined mass of all the items stored up next to the coordinates. Then I use the tilemap to project the latest item placed at those coordinates.

The array sounds like a nightmare to code around, but I also think in the long run it'll be less taxing than a few hundred sprites sitting on top of one another and a node tree a mile long. That said, those individual nodes would only be accessed by proximity, while the entire massive array would be accessed every time the player moved, searching the top of the array for any coordinates that are within reach.

I'm still leaning towards the array though. Am I going in the right direction? Or is there a better way of implementing this that I'm oblivious of?

in Engine by (33 points)

1 Answer

0 votes

Hello there, there is a node called grid container add all your items as a child of that node to organize your inventory, each item should have a script with it's info and whatsoever with sprites and whatnot, if you need anything else lemme know, hope this helps

by (76 points)

That would work as an option for inventory UI, but I don't see how it would help with managing many items on the ground.

I think I'm going to go with a hybrid of my two options. I'll have a quick reference array of the coordinates and "pile" nodes. The nodes will hold an array of the items on that spot and manage space capacity. I'll be using a Tilemap in conjunction so that I can update the cell's id instead of using sprites. This has the added benefit of meaning I can simply check my surroundings each move for a tile that isn't -1, instead of having to search an array every move if one is near me.

Thank you for your suggestion just the same. I'll probably do something like that when I get around to UI implementation.

Okay then good luck with your project

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.