Declaring the default pawn class in GameMode
Hi there guys! Sorry for the really noob question, but I want to declare the class with the default Pawn in the GameMode directly in C++ (since in my project it wouldn't change). And I challanged myself to create the whole project without a single blueprint (execpt of the really really simple stuff, like doors or moving platforms).
So as fat as I understood, There is a UPROPERTY in the AGameMode.h class that should get the default pawn class (DefaultPawnClass), and it's type is APawn. So my question is, how do I get the path for the class? (Without fstream.h of course :p). I saw that it might be achived by using the ConstructorHelpers::FObjectFinder
Here is the code I'v tried (the syntax is probably incorrect):
So how can I do that?
I think the preferred method is to set it to a BlueprintClass that is of your custom class type, so that you can then easily edit it within the editor rather than having to always edit code to change settings. For example this is done in the FirstPerson template:
Where the template has created an instance of TP_FirstPersonCharacter as a blueprint called 'MyCharacter'.
answered Jul 23 '14 at 08:06 PM
Assumed that your game mode file(called as MyGameMode.h) is in Source folder, so you have to include HPCharacter.h, and declare like below.
For either FObjectFinder or FClassFinder, these are used to find Blueprint layer from the game folder, aka Content folder in the project.
answered Oct 01 '18 at 05:07 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here