I’m sure this is a pretty simple problem to resolve, but I’ve had a bit of difficulty with it.
Looking at WorldInfo from the Rocket Editor, it points to Thirdperson.GameInfo.
I look at that within Visual Studio and this is what I see:
#include "ThirdPerson.h"
AThirdPersonGameInfo::AThirdPersonGameInfo(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// Non-property initialization
// Property initialization
static ConstructorHelpers::FObjectFinder PlayerPawnOb(TEXT("Blueprint'/Game/MyCharacter.MyCharacter'"));
if (PlayerPawnOb.Object != NULL)
{
DefaultPawnClass = (UClass*)PlayerPawnOb.Object->GeneratedClass;
}
}
My DefaultEngine.ini file looks like this (I’ve added the controller):
[URL]
Map=/Game/Example_Map
LocalMap=/Game/Example_Map
TransitionMap=/Game/Example_Map
GameName=ThirdPerson
[Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_ThirdPerson",NewGameName="/Script/ThirdPerson")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_ThirdPerson",NewGameName="/Script/ThirdPerson")
+ActiveClassRedirects=(OldClassName="TP_ThirdPersonGameInfo",NewClassName="ThirdPersonGameInfo")
+ActiveClassRedirects=(OldClassName="TP_ThirdPersonCharacter",NewClassName="ThirdPersonCharacter")
+ActiveClassRedirects=(OldClassName="TP_ThirdPersonController",NewClassName="ThirdPersonController")
What am I missing here? My game continues to use PlayerController instead of my new ThirdPersonController.
The PlayerController class to use for a game is set in your GameInfo class using the PlayerControllerClass variable, much like how the Pawn class is set in your example.
Those class redirects in the .ini file are for something else entirely and not something you should be using on a regular basis.
Silly question - do you know what I need to write in the gameinfo class to change the controller being used? Right now I’m just looking at this (from the Third Person sample)
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#include "ThirdPersonGameInfo.generated.h"
UCLASS(minimalapi)
class AThirdPersonGameInfo : public AGameInfo
{
GENERATED_UCLASS_BODY()
};
I don’t see anything about ThirdPersonCharacter in there though?
keeping in mind my game is called CustomGame and my PC class is called CustomPlayerController, take a look at my code:
only required at your GameInfo.cpp file
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#include "CustomGame.h"
ACustomGameInfo::ACustomGameInfo(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// Non-property initialization
// Property initialization
static ConstructorHelpers::FObjectFinder PlayerPawnOb(TEXT("Blueprint'/Game/Characters/CustomCharacter.CustomCharacter'"));
if (PlayerPawnOb.Object != NULL)
{
DefaultPawnClass = (UClass*)PlayerPawnOb.Object->GeneratedClass;
}
PlayerControllerClass = ACustomPlayerController::StaticClass();
}
Exactly what I was looking for, thank you.
I was tinkering with that class as well, and on the third person example it uses this syntax:
static ConstructorHelpers::FObjectFinder PlayerPawnOb(TEXT("Blueprint'/Game/MyCharacter.MyCharacter'"));
if (PlayerPawnOb.Object != NULL)
{
DefaultPawnClass = (UClass*)PlayerPawnOb.Object->GeneratedClass;
}
When I tried to copy that syntax for my new controller, I realized there is no DefaultControllerClass property, and instead, only DefaultPawn Class.
So I can use your format and it should work correctly now. Thank you!