Godot Version
Godot 4.5.1
Question
I want to create a system in my game that generates three random upgrades and let's you pick one. I have a small idea but am quite new to the engine so I don't know how to put it into practice.
Godot 4.5.1
I want to create a system in my game that generates three random upgrades and let's you pick one. I have a small idea but am quite new to the engine so I don't know how to put it into practice.
Did you already finish some of the basic tutorials, like this one? If not, this might give you some ideas on how to approach building systems in Godot.
If you already have an idea on how to do it - try to implement it and share it with us, we can help you tune your idea.
If you’re struggling on how to implement upgrades themselves, here’s a high-level approach I took in my roguelike game:
Step 1. Define a PlayerAttributes class that holds all the player info.
Step 2. Add a function to each item, which inherits an Item class, to take a PlayerAttributes argument and do something to it (e.g. doubling the damage variable)
Step 3. To recalculate stats, the player will define a new PlayerAttributes, loop through each item and call its function, and set its old attributes to be these new attributes.
Step 4. Wherever you need these stats, you’ll now reference them with dot notation (like attributes.damage)
Step 5. To add new triggers, like “+5 damage when you take damage”, add new functions in the player that call functions in each powerup letting them know to trigger that. Override the virtual function if the powerup needs to.
This system worked well and was scalable for my previous roguelike game, Wombo, and I’m going to implement it very soon in my next game. Pretty much any operation where stats are changed works pretty well with it.
I have the game basically done, just need this system for the final prototype. I can do the UI and think I can make it work, I just need help with random upgrade selection.
What exactly do you mean by that?
Sounds strange that you’ve made a complete game but have problems with a trivial thing like random selection.
I have more of a prototype but don’t know how to setup the random parts of the ui. I can make the upgrades work but I have always struggled with control nodes.
Well if you want some specific suggestions you’ll have to describe the functionality you’re after in more detail. Describe how is the whole thing supposed to look and function from player’s perspective.
At the end of a floor, I want the player to be taken to a scene that gives them 3 options of upgrades from a pre-determined list. I don’t understand how to get the control nodes to display a randomly selected upgrade.
Instantiate nodes/scenes that correspond to selected upgrades and add them to the scene tree.
Thanks a lot, seems like such a simple idea now that you have said it.