get all actor of at random class

I don’t understand how my code could be wrong, i haven’t even started to code the system for now !
I’m trying to understant how to do the system before, because it’s not clear in my mind.
So, i changed the variable into a class reference like you said :slight_smile:
Now, let’s take back the problem from scratch so it will be more understandable.
The player will be able to talk to a man in a camp. When the player will interact with him, a menu will pop up, the pet shop menu.
In this pet shop, every 10 minutes, the pet buyable will be randomized.
Everything is done, exepting the randomizing system !
So, here is some pics of the shop menu, the pnj (who is the ‘‘shop blueprint’’ like you asked), and here is my character, even if i don’t really know how it could be useful…?
Thanks again for your time and i’m sorry if it’s something simple for you, but we all started somewhere haha !

So now, i just need to know how to randomize the name, if i understand this, i could do the same for every other variable ! I just don’t know what to do, so i’m following your advices step by step

Why even bother with this mess? Have each of your 10 pets put into a “class” array. Yes, make them all children of a master BP for simplicity but basically you need an array of all potential “pets” as a class reference. Once you have that create a function that takes the array, uses the “get random int in range” node with values between 0 and 1-max array length. Have this function output the “random” class selected. Use that output value as an input to a separate function that then updates all of you HUD elements. When the player “buys” a pet, give the player whatever stats/inventory item/power ups etc that are attributable to the purchased pet class.

Have each of your child pet BPs have a function on begin play that creates a random name and stat from a base array that holds all of the potential names/stats/

ok now you have on clicked shop to show the shop UI.

-I want you to make that “Pet_List” expose on spawn checked true and don’t make it an array. but ordinary class.

-instead create a new variable same as the “Pet_List” array variable in the “Elevuer?”, on clicked event to show the shop HUD to be attached there.

  • do the same as you did in the “Pet_Shop” the “Get” function with randomization then attach the end of “Get” to the “Create Widget” Node after you make the “Pet List” in the “Pet_shop” expose on spawn and not an array.

-now in the “Pet_Shop” to show the name function, just grap the “Pet_List” that you made “Not Array” and get default variable and attach it.

so each time you open the shop it will randomize a pet for you.

to make it change each 10 minutes or so, it needs a stand alone custom event to be triggered every 10 minutes in the “Elevenur??”. but let me give it all to you so I don’t come back here again =).

there as below:

  • create a custom event and call it “Pet_random”.

  • Make a new variable and call it “Pet” or whatever, to be the same as “Pet_list” class type but not an array.

-Grap the “Pet_List” and do the randomization function and attach the end of get to the “Pet” to set it.

-OnEvent BeginPlay, attach a node called “Set Timer By Event” attach the red “Event” executable to the custom event “Pet_Random” and check Loop to True and put atlest 10 seconds to test the logic.

Like this:

now this is done.

go to your “OnActor Clicked” event to open the shop menu,
and instead of making it random each time you open the shop, you want to put “Pet” variable in the “Create Widget” node and done.

will shuffle pets every 10 seconds for you.

Thank you very much.