Skip to content

Controllers

If you are using a Faction System, it's very likely that you will require your AI Agents to properly react to it, displaying the correct Attitude towards members from the same and other Factions.

Maybe you need to also separate your players into different teams and have means to detect which team a Player belongs to.

While using this plugin, the recommended way to do so is through your Controller classes. More specifically, the AIController and the PlayerController.

The AI Controller

The Faction System provides an AI Controller for you: the NinjaFactionAIController.

This section will explain what it does, but also give you an overview of what would be necessary in case you must implement your own AI Controller for some reason.

The most important functionalities for the AI Controller are the ones inherited from the IGenericTeamAgentInterface, responsible for introducing the concept of Teams and Attitudes into the AI Framework.

The core AIController class already implements this interface This means that the main goal here is to connect these functions to the Faction Subsystem.

C++ Only

The IGenericTeamAgentInterface and its methods can only be implemented in C++!

Function Details
GetGenericTeamId Provides the Team ID assigned to the Pawn's Main Faction.
GetTeamAttitudeTowards Uses the Attitude Solver to determine the Attitude.
OnPossess Retrieve the Pawn's Faction and update the Perception System if needed.
OnUnPossess Revert the above.
Reference Controller

It's strongly recommended that you either use or subclass the provided AI Controller, but if you can't, then make sure to take a look on how it it was originally implemented!

Once you are done, make sure to set the AI Controller to your Pawn or Character.

The Player Controller

The Faction System provides an AI Controller for you: the NinjaFactionPlayerController.

This section will explain what it does, but also give you an overview of what would be necessary in case you must implement your own Player Controller for some reason.

As before, the most important functionalities would come from the IGenericTeamAgentInterface, but in this case, the Playercontroller does not implement it by default, so that would be an additional step.

C++ Only

The IGenericTeamAgentInterface and its methods can only be implemented in C++!

Function Details
GetGenericTeamId Provides the Team ID assigned to the Pawn's Main Faction.
OnPossess Retrieve the Pawn's Faction and update the Perception System if needed.
OnRep_Pawn Same as above, but on the Local Client.
OnUnPossess Revert the above.
How about the GetTeamAttitudeTowards function?

The GetTeamAttitudeTowards function is only called by AI agents to determine their attitude and perception relevance. It's not necessary for Player Controllers.

Reference Controller

It's strongly recommended that you either use or subclass the provided Player Controller, but if you can't, then make sure to take a look on how it was originally implemented!

Once you are done, make sure to set the Player Controller to your Game Mode.