DefaultPawn in c++

Hi! I’m learning UE5, and i have question about gamemode in c++, i’ve created GameMode in c++ and now i want to set mycharacter.cpp as pawn how i can do that?

Hi @Displaynonamee,

You would include the header to MyCharacter in the Header file of your GameMode.h

Next you would set the DefaultPawnClass inside your GameMode constuctor.

AMyGameMode::AMyGameMode()
{
    // Set the default pawn class to your custom character class
    DefaultPawnClass = AMyCharacter::StaticClass();
}

Hope this helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.