Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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):

 static ConstructorHelpers::FObjectFinder<APawn> pawnClass(TEXT("class'Game/Source/HP/HPCharacter.h'"));
     DefaultPawnClass =  pawnClass;

So how can I do that?

Product Version: Not Selected
more ▼

asked Jul 23 '14 at 07:31 PM in C++ Programming

avatar image

30 4 3 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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:

 static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Blueprints/MyCharacter"));
 DefaultPawnClass = PlayerPawnClassFinder.Class;

Where the template has created an instance of TP_FirstPersonCharacter as a blueprint called 'MyCharacter'.

more ▼

answered Jul 23 '14 at 08:06 PM

avatar image

zeroexception STAFF
1k 18 16 39

avatar image Mickelbil84 Jul 24 '14 at 05:01 AM

Thanks for the reply, but as I'v said, I'd really like to create the core foundations of the game without any blueprints... Also, Most of my code was inspired by the TPS Template, and I'v got the idae of the DefaultPawnClass from it :)

avatar image zeroexception STAFF Jul 24 '14 at 04:31 PM

You can try:

 DefaultPawnClass = AMyCharacterClass::StaticClass();

avatar image ViaCognita May 24 '17 at 06:29 PM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

          #include "HP/HPCharacter.h"
              DefaultPawnClass = AHPCharacter::StaticClass();

For either FObjectFinder or FClassFinder, these are used to find Blueprint layer from the game folder, aka Content folder in the project.

more ▼

answered Oct 01 '18 at 05:07 PM

avatar image

8 3 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question