Hey I am relatively new to Unreal Engine still and wanted to start with a relatively simple concept of a random perk generated system in which the player gets to select between 3 perks that appear randomly selected from a group of perks. I’ve Created some basic Perks, made a Structure chart with their necessary data /w reference to their allocated enum names.
How would I now go about with my for eg: Weapon Perks, to randomly be selected to appear in the players U.I from a selected list of perks?
Thanks in Advance!
This is what I’ve come up with so far in my level Blueprint (although not the most ideal way), it prints the names of the actors in the array randomly how would I now go about spawning one instead?
Hi NattyMatty,
There’s the SpawnActor node which is a good way to create actors in the level - but that usually accepts a “Class” rather than an actual actor reference - which is even easier anyway.
Check out:
Hi thankyou for the reply, I’ve tried using the spawn actor from class node but im only able to spawn a specified actor, I’ve categorised the 3 actors under 1 class but doesnt seem to randomly pick from them unless I’ve done something incorrectly?
My 3 weapons are classified under a parent actor/class “weapon Tile Array”
It’s a good practice to break things like that into their own classes - have a base class as something like “BP_Perk_Base” and then subclass off that with “BP_Perk_1” etc.
Then you can Spawn with “BP_Perk_1”.
It also has the benefit of being able to have a list or array of “BP_Perk_Base” and each of your subclassed perks can be stored in there, and you can call it’s methods as the specific Perk you Spawned it as.
The problem I modtly have is just with the blueprint logic, i understand all the terms of classes and arrays just moreso using the correct nodes. So atm I’ve got them all under the class “Weapon tile array” (Which is an actor just named for convinience), how would I then create sub classes from there?
Thanks again for the help.
It’s pretty straight forward, just when you create the sub perks, specify the “Weapon tile array” actor as the parent class:
Then in your level blueprint you can create an array of their classes, and choose a random one from it with the code below:
2 Likes
That is awesome, thankyou very much for taking the time to help!
1 Like