Hi, I am trying to create a search and destroy style multiplayer FPS. This is how im currently doing my team assignment logic using blueprints. The trouble is, I need to be able to add to the array ValidStarts (Player Object Reference) but unfortunately the array element from my ForEachLoop is an Actor Object Reference because its coming off my Get All Actors of Class node.
How can I fix this?
P.S. Im new to game development/ UE5.6 so please help me by explaining things simply and be patient with me. Thanks so much!!
I’m slightly confused by your question so I’m just going to clarify what I think you’re asking and then answer that, if it’s not quite what you were after let me know.
You are getting all actors of class PlayerStart it looks like, and then you are trying to see if any of those have the correct tag, and if so you are wanting to add them to an array of ValidStarts that are valid because they have the right tag? But you are having trouble because they don’t match the exact same class?
If that is the case you can simply change the array you are trying to add them to to match. In this case a PlayerStart object array.
As an aside when you set the class on a GetAllActorsOfClass node the return value will change to be objects of that class, you can always check this by hovering over the return node and it will tell you what it is.
So if you were to change the array of ValidStarts to be PlayerStart object references instead of (I think you said) Player object references, then you would be able to add the ones that are confirmed to have the correct tag to said array.
Hopefully it is as simple as that, let me know if I’ve gone off on my own tangent or something is not quite clear and I’ll be happy to clarify!
I am so stupid. After adding the “Set- All Starts” Local Varible, I didnt refresh the “For Each Loop” node so it thought it was still pulling an Actor Class Reference. I apologise for the time waste and thank you kindly for your help!!
Create a function in the GM that presorts the player starts based on an Actor Tag in the player start.
Two arrays… Attackers & Defenders
Use a Sequence node.
Then 0: Get all actors w/Tag (Attacker) → Set Attacker array
Then 1: Get all actors w/Tag (Defender) → Set Defender array
When a player Joins uses the On Post Login event in the GM to assign them to a team.
On Post Login passes a Controller reference. Use it to get the Player State then set the Team there.
Team variable should be replicated.
Now when the player spawns you can use its Player State “Team” to determine which player start array to use. Then it’s just a random from array.