Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?


Product Version: Not Selected
more ▼

asked Jun 20 '14 at 01:14 AM in Blueprint Scripting

avatar image

141 31 48 53

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

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!

alt text


enum2.jpg (196.9 kB)
more ▼

answered Jun 20 '14 at 01:55 AM

avatar image

10.5k 444 343 1081

avatar image DreamBotStudios Jun 20 '14 at 02:04 PM

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

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jun 20 '14 at 02:00 AM

avatar image

9.5k 317 202 449

avatar image DreamBotStudios Jun 20 '14 at 02:07 PM

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.

(comments are locked)
10|2000 characters needed characters left

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

more ▼

answered Jun 22 '14 at 06:56 PM

avatar image

141 31 48 53

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question