Create teams: trying to set tag on spawn

Make Team variable on Pawn or PlayerController. Make sure every projectile has set shooting pawn as owner, if you do traces then i guess you need to pass it other way. Then when you calculate damage make a condition if team of shooting player and hitted player are not match, if not don’t make it take a damage

I have a MPgame setup where anywhere between 1-8 players can be in the game at once.

When the game starts and or when a player joins I want them to be assigned a tag, like “team1” or “team2”
If players are on the same team I dont want them to be able to shoot each other but be able to shoot the other team.

Right now everyone can kill everyone and there’s no way to separate who wins essentially.

If tags aren’t the right way to do this, let me know if there is a better way. Searching returned nothing really.
Thanks!

I’m using line traces.

And when the character joins the game, they need to be assigned a team… team 1, 2, 3 or 4

then do it :slight_smile:

I’ve done it. Unfortunately your advice wasn’t helpful though.
It was much more complicated than I initially thought.

My setup is too complicated to post it all… but essentially:

What I did:

  • create an array per team on custom Game Instance (team1, team2)

  • each array has four bool entries set to false by default

  • after spawn in the custom player controller, using a series of loops and GETS I find the team1 array in gameinstance (cast) and check each of the four entries for a true… if none, then set one of them to true and then cast to myplayerstate and set a local name variable to “Team1”. Everytime an element in the array is set to true I increment a separate variable by one Team1Count

  • The next time a player joins it will do the same thing except if it finds a true in the array at all it will then go to the next array Team2 in game isntance and do the same process… Incrementing Team2 variable by 1

  • Subsequent players will enter the loop, before anyone is assigned a team, I compare Team1 and Team2 incremental values… if team1 is less than or equal… current player joins team1

  • In the beginplay of the CharacterBP I have a set teams function, that sets a local characterBP name variable to “Team1” or “Team2”, its a cast from MyPlayerState variable set earlier

Now after a hitting or shooting someone, just before applying damage, cast to the charBP of the HIT player and compare their team to yours, if no match… death by snu snu, etc…

Can you explain how it’s done or point me towards any guides?

Hello, even if you structure is complicated, I would be very glad to see how your teams set up works ! It’s really impossible to see how it works on Internet, no tutorials or efficient help :slight_smile: