Actor always invalid, call from GameMode

Hey guys,

I’m calling my actor ‘Deck’ from my gamemode blueprint, but the ‘Deck’ always returns invalid. I’ve also added the actor to the scene but it keeps coming up invalid.

Deck’s variable type is the Deck Blueprint (an actor).
What am I doing wrong here?

Help is appreciated :slight_smile:

Setting the variable type to the BP class won’t actually set the variable to that BP class. Doing that just means that the only input type you can set the variable to is of that class. What you need to do is cast the deck BP then set the variable from the cast return value.

As to how you can get a reference to the deck BP in order to cast it is tricky. For example, casting to the player controller is simple because you can “Get Play Controller” then cast from that function to your controller but you can’t do that with you custom Deck BP.

Often time what I do is set a reference to a BP after I spawn it, into a BP that is easy to grab from anywhere, like the player controller or like you are attempting, the Game Mode. What I would suggest is to create the variable of Deck in the Game Mode like you already did, then in the Event Begin Play of your Deck BP, make a call to your game mode, cast that call to your custom Game Mode (like you would the player controller or character) then Set the variable (pulling from the return pin on your cast) using a “Self” reference of your deck BP.

Hope this helps! If it did please do me a favor and accept the answer! If you have any other questions then let me know and I’ll do what I can to help.

Sorry for the lack of response, I’ve been on a short vacation.
I will try to follow your instructions tomorrow. Thank you so far!