Tutorial: Your First 60 Minutes with StateTree

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:

  • ASTCharacter should have ACharacter as base class.
  • Make sure PosssessedBy calls Super::PossessedBy like I mentioned.
  • ASTPlayerController should have APlayerController as base class.

On Blueprint:

  • Setup BP_ThirdPersonGameMode to use STPlayerController as the Player Controller Class.
  • Reparent BP_ThirdPersonCharacter to the STCharacter class by going to the BP Class Settings and changing the Parent Class in the details panel.

Now, when you play:

  • The PlayerController for you, the human player, will assign itself the team ID 2, because of STPlayerController’s construction code.
  • The Character, when possessed by the PlayerController, will execute the STCharacter’s version of PossessedBy and copy the PlayerController’s ID for itself, so it’ll be 2 as well.
  • The AI and enemy character will have the default ID of 255. That will make them enemies because the default attitude solver for the FGenericTeamId deems different IDs as ETeamAttitude::Enemy. That default solver is the DefaultTeamAttitudeSolver method in AIInterfaces.cpp.
3 Likes