Download

Can't set default properties for my GameMode

Hi!

So, I have a game mode:



UCLASS(minimalapi)
class AHShooterGameMode : public AGameMode
{
	GENERATED_BODY()

public:
	AHShooterGameMode();

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
	AGenerator* A;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
	AGenerator* B;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)
	AGenerator* C;
};


And I want to set a default value for A, B and C through a blueprint child, but the editor won’t let me.
c61bd76fa9b97b299c22d4324279409ae0173491.png
Even though they aren’t greyed out, I still can’t select the properties. What am I doing wrong?

With this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
AGenerator* A;

You can pick AGenerator class object placed on level. Tell us what you want to do with that property or what you expect from that property.

Have you created Blueprints that inherit from AGenerator? I’m assuming that the list is empty when you select the drop down

I have a generator blueprint which inherits from the C++ class, and I have 3 of them in the level. They do show up in the drop down list, but when I click on them, nothing happens. It was difficult to screenshot

You still stuck on this? I had something similar happen, seems I needed my UPROPERTY to be a TSubclassOf<T> instead of Actor*

This won’t work because the Game Mode doesn’t exist in the level, it’s created dynamically - therefore you can’t store a reference to those objects inside it.

You need to use TSubclassOf<AGenerator> - and spawn the actors with the GameMode. Then you can use them.