I have a class in C++ that I want to access in BP. It appears to be fine in C++ but in BP I get Accessed None errors when I try to use it in BP. Here is the class declaration that I am trying to use in BP

class ZOMBIEHORDE_API UQualitySettings : public UObject


    // constructors


    // class functions and properties

I am holding on to it in the GameInstance as below so I can access it through the GameInstance reference.

class ZOMBIEHORDE_API UZombieHordeGameInstance : public UGameInstance



    UPROPERTY(BlueprintReadOnly, Category = "Zombie Game Instance")
    UQualitySettings *QualitySettings = nullptr;

And GameInstance .cpp

    QualitySettings = NewObject<UQualitySettings>();
    ensure(QualitySettings);// this passes and does not throw an error

This shows how I am accessing it in a widget blueprint.

enter image description here

So how can it be that accessing QualitySettings in BP is None?

  • \$\begingroup\$ You've shown the code for UZombieHordeGameInstance but your blueprint code references BP_ZombieHordeGameInstance. \$\endgroup\$
    – Rotem
    Dec 29 '19 at 1:12
  • \$\begingroup\$ Have you tried pulling a Print String off of the Cast Failed execution pin of the Cast to BP_ZombieHordeGameInstance. It may be that it's not even getting that far when trying to call the Quality Settings \$\endgroup\$
    – Stephen
    Jan 3 '20 at 10:44
  • \$\begingroup\$ I ended up doing a refactor of the code that avoids this. I never actually got to a solution. \$\endgroup\$ Jan 4 '20 at 3:22
  • \$\begingroup\$ You should try and give your UObject a UPROPERTY - The GC assumes all objects that inherit from UObject have one. Try adding private: UPROPERTY() UQualitySettings* SelfRef = this; in the header file. \$\endgroup\$
    – Natalo77
    May 21 '20 at 14:24

Perhaps the reflection system doesn't like the

UPROPERTY(BlueprintReadOnly, Category = "Zombie Game Instance") 
UQualitySettings *QualitySettings = nullptr; //try to remove the = nullptr from here.

Generally in UE4 we set the variables in constructor because of CDO and reflection system on-behalf.

  • \$\begingroup\$ I'll try but I would think since I'm setting the QualitySettings variable in the constructor and test its valid by calling ensure on it, that BP would see it as not nullptr anymore. Although I do know UE4 has a way of doing things sometimes that doesnt seem logical lol. I'll try it and see what happens. \$\endgroup\$ Dec 23 '19 at 12:53
  • \$\begingroup\$ It was just a suggestion, although there is probably a reason noone uses the assign operator in var/property declaration (no where in UE4source as well). \$\endgroup\$
    – ColdSteel
    Dec 23 '19 at 13:14
  • \$\begingroup\$ I still get the error. \$\endgroup\$ Dec 23 '19 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.