Yeah, the C++ part of that tutorial seems to assume you’ll only try to do it if you are already very familiar with Unreal. It doesn’t even say you need your Blueprints and GameMode setup to spawn the new types of PlayerController and Character.
On code, besides overriding the functions as described in the tutorial:
ASTCharactershould haveACharacteras base class.- Make sure
PosssessedBycallsSuper::PossessedBylike I mentioned. ASTPlayerControllershould haveAPlayerControlleras base class.
On Blueprint:
- Setup
BP_ThirdPersonGameModeto useSTPlayerControlleras thePlayer Controller Class. - Reparent
BP_ThirdPersonCharacterto theSTCharacterclass by going to the BPClass Settingsand changing theParent Classin the details panel.
Now, when you play:
- The PlayerController for you, the human player, will assign itself the team ID
2, because ofSTPlayerController’s construction code. - The Character, when possessed by the PlayerController, will execute the
STCharacter’s version ofPossessedByand copy the PlayerController’s ID for itself, so it’ll be2as well. - The AI and enemy character will have the default ID of
255. That will make them enemies because the default attitude solver for theFGenericTeamIddeems different IDs asETeamAttitude::Enemy. That default solver is theDefaultTeamAttitudeSolvermethod inAIInterfaces.cpp.