Topic was automatically imported from the old Question2Answer platform.
Asked By
mattkw80
This is more of a game design question then a Godot specific question.
I’m making a game similar to Rimworld where every NPC and Enemy has many properties and abilities.
What structure should I use to allow them to see something and take note of it so they can go to it later?
ie: A Hunter wanders the map… see’s some apples, and in the future will know they can return to that location on the map to retrieve the apples.
I already have ‘inventory’ for them - where each piece of inventory is a Scene and they have a list if scenes. I used a Node2d… not actually a list - so I guess my actual question is - should these scenes be stuffed into a Node2D or should I have been making an array or list of Nodes? (The nodes being inventory and memories).
Thank in Advanced for reading.
Thanks all - I’ll review and try all of this in detail.
There are many ways to do this, what you want as a ‘memory’ can be a value stored somewhere. You can use Array, Dictionary or Variables. For example, you could do:
This is a example of a data structure using dictionaries, which you can make whatever you want and nest them whoever you want. For your Hunter to ‘remember’ where the Apples are is easy, you access them like mentioned above, you would get the coordinates for the Apple_1.
Whoever when the Hunter will be searching for Apples? And why he would want Apples? That’s where you will need a simple AI to handle that, maybe your Hunter will get Apples if FOOD < 20% MAX or HEALTH < 30% MAX.
OR, using your own method of having nodes as a list, maybe you could create a Position2D to them apples, and create a ‘Memory’ node to your Hunter, like you created a Inventory. So it can be a Inventory of Memories in a sense. and maybe you can add a Label inside that Position2D to reference a itemname for your Hunter.
So you have the coordinates of the apples from the position2D and the inventory item reference stored in the label.