Expose Gamemode subclass default pawn value to editor

I am trying to expose the default pawn variable of a Gamemode subclass to the editor. I did not want to create a derived Blueprint class just to expose one value to the editor, which I think would be rather crude and cumbersome, and I did not want to hard-code the values (which would have been equally as crude, albeit simpler and far less cumbersome). So, I set out for an alternative solution. I attempted to use a UPROPERTY() macro, which seemed the simplest and most obvious solution. This caused the compiler to throw errors for no discernible reason. The build output simply stated that Epic Games’ Build.bat had “exited with code -1”, causing the build to fail because the compiler threw an “OtherCompilationError” (5) as a result, which is vague and entirely unhelpful.

Here is the line in the subclasses’ header file where I declared the variable and exposed it to the editor with a macro:

UPROPERTY(EditAnywhere, BlueprintReadWrite) TSubclassOf<APawn>* GamemodeDefaultPawnClass;

Here is the line in the class file where I set the default pawn class of the Gamemode subclass:

DefaultPawnClass = *GamemodeDefaultPawnClass;

Does anyone have any idea why the compiler might be throwing errors, or alternate solutions which are not overly convoluted, cumbersome or crude (or at less so than those I’ve already considered)?

Instead of using TSubclassOf* just use TSubclassOf. TSubclassOf is a template that wraps a UClass* which limits it to only certain types. Essentially what you did was make a UClass** which is probably not what you intended and is no wonder why UE build tools are complaining at you.

Just change your GamemodeDefaultPawnClass to:

UPROPERTY(EditAnywhere, BlueprintReadWrite) TSubclassOf<APawn> GamemodeDefaultPawnClass;

And make sure when you assign DefaultPawnClass you don’t dereference it.

DefaultPawnClass = GamemodeDefaultPawnClass;

Didn’t work; compiler throwing same errors. This was likely something that needed to be corrected, but it doesn’t solve the problem.

If you are still receiving an error then I can’t help but think that these two lines of code you provided are only part of the issue. Think you could edit your post and add the whole build output?

These are the only edits that I’ve made to what is essentially autonomously-generated startup content. I haven’t added anything else. It is almost certainly just these lines that are keeping it from building.

Actually, try adding a Category specifier to your UPROPERTY. Something like UPROPERTY(Category=MyCategory, EditAnywhere, BlueprintReadWrite)

Still causing build errors.

Sorry to hear that, not much else I can do without seeing the logs and/or code. Good luck!

Thank you for your time.

I don’t understand what you are trying to do. The DefaultPawnClass variable is exposed to the editor. This is what it looks like in GameMode.h

	/** The default pawn class used by players. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Classes)
	TSubclassOf<class APawn> DefaultPawnClass;

Where are you assigning the GamemodeDefaultPawnClass a value that you can’t assign DefaultPawnClass the value directly?

Where are you assigning the GamemodeDefaultPawnClass value to DefaultPawnClass?