Teams
Every Pulse plugin asks the same question when it needs a team (who an attack may hit, who may build on a claim, which AI is hostile): Pulse::Team (Team/PulseTeam.h, module PulseFoundation). A team is a gameplay tag; Pulse Foundation brings the common ones and games add their own below Pulse.Team:
| Tag | Team |
|---|---|
Pulse.Team.Player | Players |
Pulse.Team.Enemy | Enemies of the players |
Pulse.Team.Neutral | No one’s enemy: animals, traders (the team rules of PulseCore and PulseAI never make it hostile) |
Where the team of an actor comes from
Pulse::Team::GetTeam(Actor) looks in this order and takes the first team source it finds:
- The actor itself: the actor or one of its components implements Pulse Team Interface (
IPulseTeamInterface), else it has a Pulse Team component (UPulseTeamComponent). - Its player: controllers, pawns and actors owned by a player (weapons, projectiles) use the player state (player resolution). So the pawn, the controller and the player state of a player have the same team, also after a respawn.
- The pawn of a controller without player state (an AI controller).
- Its owners: an AI’s projectile has the team of the AI pawn that owns it.
An actor without a team source has no team (an empty tag).
| Function | What it does |
|---|---|
GetTeam(Actor) | The team, empty for none. |
IsSameTeam(A, B) | True when both have a team and it is the same tag. Two actors without a team are not in the same team. |
SetTeam(Actor, Team) | Sets the team on the authority, on the team source above: on a player’s pawn it sets the team of the player. Logs and does nothing on clients and for actors without a team source. |
FindTeamSource(Actor) | The object that holds the team (the interface object or the component). |
| In Blueprint: Get Actor Team, Is Same Team and Set Actor Team (category Pulse | Foundation | Team). |
Team component
The Pulse Team component holds a team tag and replicates it to every machine (push model). Set its team on an enemy Blueprint as the start team, or at runtime with Set Team (authority). On Team Changed (Blueprint) and OnTeamChangedNative (C++) fire on every machine when the team changes.
For players, turn on Project Settings > Pulse > Foundation > Automatic Components > Team Component: every player state gets the component when it spawns. A team component on a player state that starts without a team gets the Player Team of the same settings page (default Pulse.Team.Player; empty: players start without a team).
Own team logic
A game with its own teams (a team per guild, teams from a match) implements Pulse Team Interface on the actor or on a component of it:
- Get Pulse Team returns the team.
- Set Pulse Team sets it (only called on the authority); return false when the game does not allow it.
The interface wins over a team component on the same actor, and the player state works as the source for the whole player, as above.
// The team of a game's own guild component on the player state
UCLASS()
class UMyGuildComponent : public UActorComponent, public IPulseTeamInterface
{
GENERATED_BODY()
public:
virtual FGameplayTag GetPulseTeam_Implementation() const override { return GuildTeam; }
virtual bool SetPulseTeam_Implementation(FGameplayTag Team) override { return false; } // guilds change elsewhere
UPROPERTY(Replicated)
FGameplayTag GuildTeam;
};