How should/could I create a team system?

Hello! I have been looking trough Youtube to find a tutorial for a team system for my Hero Shooter game, but didn’t find any. I also have no idea on how I could do one from scratch.

(Simple Team A and Team B idea)

If you have any tips and tricks, or know a tutorial, I’d appreciate it a lot!

There is already a team system integrated . If I remember correctly if they are not in the same group you can consider as enemy. However you can also assign 1 as natural (I just can’t find where I did now but its possible)

0-AI
1-Natural
2-Player

2 is enemy to 0,1

However if you are looking for something more grift system design let me know.

If you implement the IGenericTeamInterface you can get set ids on runtime thus you can do switches however as far as i remember there was no events, so advice to make a OnFactionChanged event something to bind other systems.

Something happens on combat, you cast a spell to enemy “mind control” ai becomes friendly to your team.

How to Implement BP Only :
Add this in your Controller GenericTeamAgentInterface

Get this plugin from marketplace its free, if you don’t have and add it to your project/engine.

After you search team

You can do something like this on pawn

Make a function or custom event. Call set team in begin play or whenever you need with team id. Sets the controller teamID (Better have IDS on controller but your choice). Make an event as optional to let systems know you changed team.

If you do with C

#include "GenericTeamAgentInterface.h"

UCLASS()
class MGPLAYERCHARACTER_API AMGPlayerController : public APlayerController, public IGenericTeamAgentInterface
{
	GENERATED_BODY()

public:
	AMGPlayerController(const FObjectInitializer& ObjectInitializer);

	virtual void OnPossess(APawn* InPawn) override;


private: 
	// Implement The Generic Team Interface 
	UPROPERTY(EditAnywhere, Blueprintable,  Category = "MG Player Controller")
	FGenericTeamId TeamID = 2;
	
	FGenericTeamId GetGenericTeamId() const;

	UFUNCTION(BlueprintCallable, Category = "MG Player Controller")
	void SetGenericTeamID(int NewTeamID);
FGenericTeamId AMGPlayerController::GetGenericTeamId() const
{
  return TeamID;
}

void AMGPlayerController::SetGenericTeamID(int NewTeamID)
{
  TeamID = FGenericTeamId(NewTeamID);
  IGenericTeamAgentInterface::SetGenericTeamId(FGenericTeamId(NewTeamID));
}

Hi! Thank you for the help, though I got stuck on the “Set generic team ID” part, as I don’t see a node like that. I’m definitely just missing something here as I haven’t used Unreal much yet.

Oh and also I’d like a simple team system of “one team versus another” is there a easier way to do that, or do I follow the picture you send earlier?

Hi, make sure you enabled the plugin in the plugins panel.

Also make sure that you added the GenericTeamInferface on the “ClassSettings” of your pawn.

Get a refence to self node and search for team, it would be there.

Since you asked about making a team and an easy way of doing things, let me put it this way.

A team is just an identification. If I say Besiktas Sports Team = 0, and Juventus = 1, then we simply have identifiers.

You can create an integer variable anywhere on your pawn and set it to 0 or 1.

After that, you can build whatever logic your game needs. You can make many functions just with that identifier.

If → AttackTarget.TeamID != 1 → DoAttack
or
OnTrackFinishLineBox → Car.TeamID == 0 → Print(“Besiktas Wins”) else Print(“Juventus Wins”)

If you have an identifier, that’s basically a team. A team system is what you build on top of that identifier.

Ah yeah I see the problem, I downloaded the plugin but forgot to enable it ;_; I’ll spend the next day figuring this all out, thank you for the help!

1 Like