How To Add a Enum By An Array?

I have a multiplayer game(with 2 players) and curious how to add an Enum(TeamA) and Enum(TeamB). I know it would be done at Being Play using an Array and Loop, but not sure how its done in Blueprints. Could someone post a blueprint example of adding/inserting an Enum to MyCharacter blueprint so I can setup the 1st Player to be on TeamA and second player on TeamB?

Thanks

#Adding Enums

It’s easy!

#Conten Browser->Misc->Enumeration

Right click in content browser, Misc->Enumeration

Then after editing this asset you can go into any BP and make a new variable that uses this new Enum data asset!

#Your Case

Make your own custom player contorller class or use the Character BP

Add a new variable MyTeam that has your new enum as the data type

at runtime you can set the value of this enum to be anything you want

#Random Team

convert a random range integer into a Byte / try to plug it into a Set on your team enum for your character / player contorller

#Switch on Enum

And then you have the awesome power of Switch on Enum!

Rama

1 Like

in the content browser, go to new > miscellaneous > enumeration. add a few type identifiers ( TeamA, TeamB,… ), save the enum, then open your MyCharacter blueprint, create a variable called “teamID” and change its type to your custom enumeration. you could set these in the level blueprint using postBeginPlay, or you could set these in your custom game mode.

but an easier way is to just make teamID an integer. that way, you can have some game modes where everyone gets their own team, and some where there is only 2 teams.

Thanks Rama, I have been following a lot of your post on the forums and I greatly appreciate your answer.

I am curious how would you assign the teamA or TeamB to player at begin play? I am using MyCharacter BP for all players, do I simply set “MyTeam” with Random Integer and this will assign a Team to each player?
I understand the switch, but how would one set Player 1 to Team A and Player 2 to Team B.

Then, how does one know which team they are on? So I can setup collisions.

Lastly, for collisions of bullets (where the bullet may hit oneself)… would you use HitEvents or Overlap events?

Thanks a bunch

Thanks for the feedback, That Set Part, is where I get a bit confused, do I just set TeamID one time, and it will set for each player. Do I need to loop this or something? I am unsure how one would set the team ID for each player.

Hope this helps someone, I believe I found a decent solution thus far… on how to do the entire process for setting multiplayer for two players so one can use event hits and know who is getting hit and who is not.

I posted the blueprints here:
Blueprints Process - How To Setup Multiplayer And Tag Each Player for Collisions/etc