HDI Create a randomized rewards screen

I am trying to create a 2D rougelike turn based game. Like SlayTheSpire,
I need it to pick a random object from a group, like potions or relics.
then position sprite it creates onto the button sprite
but once its only spawning the first object within the group.

I have it setup so once enemies health = 0 change the variable to 1 to intiate the rewards screen.
Then it shows the rewards layer with just the button select sprites.
Im just stuck this is my first game I am trying to make and I cant figure this out.
Thanks in advance

1 Like

Here is how I would pick a random object (not sure if this is the optimal way but it is simple and easy to implement). Rename the objects you want to spawn in numbered order card1, card2, card3, etc. In the create object by name argument you can do something like this “card” + ToString(RandomInRange(0, 10)), and it will choose a random value (0 through 10) and spawn one of the items whose suffix is associated with the random value. You could explore some of the extensions or array tools as well.

I’ll try that later and get back to you thanks

Yes this did work thank you very much