Selected blueprint in a UPROPERTY is not visible, but functionnal

Hello!

Something different from the usual, instead of something not working, and I don’t know why, something IS working, and I don’t know why!

I made this UPROPERTY in one of my classes.

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gift)
		AMuhPickupItem* gift;

Then, I go in UE4 and the blueprint editor, and try selecting which blueprint shall be the gift.

41023-selecting.png

As of now, its working quite well. Then, I choose BP_MuhCow, go back in the main window and try it out. It’s working perfectly! Not sure if its relevant, but basically, gift is the object that appears in the player’s inventory when they get close enough to a NPC.

Then, I go back in the BP editor, and, despair :

41024-none.png

The blueprint works well, I get the “gift” selected in the first pic alright, but it doesn’t show after. At least it works, but I’d like to be able to see which gift it is at a glance.

Are you actually wanting to specify:

  • A blueprint class (a type of object - give the player A cupcake)
  • A blueprint object (a specific object in the level - give the player THAT cupcake)?

At the moment you’re doing the latter, which is why the drop down selector shows objects in the world. I don’t know the details obviously but if I was making something similar, I’d be picking a class instead and instantiating a new object in the inventory.

I suspect the specific object you’re selecting is being destroyed or unloaded at some point, which zeroes out the gift pointer.

Consider using TSubclassOf gift; instead, and making a new instance when you give it to the player.