[RESOLVED] How to cast an Actor (from Persistent Level) from GameMode Blueprint?

Hi all, I’m very new to Unreal Engine and Blueprints. I’m trying to create a board game whereby the board game tiles are procedurally generated (ie. grid array index & vector coordinates). I’ve managed to successfully create that in Level Blueprints.

But I realised I could not reference those variables (index/coordinates) because they were created & stored in Level Blueprint. I read from other forums that I should create them in Game Mode/Game State Blueprint instead

So I tried copy & paste them in Game Mode Blueprint (already setup in Project Settings), and when I hit compile it came back with an error saying it cannot cast/refer to a Targetpoint Actor that was initially accessible from Level Blueprint (Persistent Level). I used that Targetpoint Actor to procedurally spawn Tiles Actor on to the Level.

How do I reference that Targetpoint Actor from Game Mode Blueprint? or am I approaching this method wrongly?

You don’t have to do it in the game mode etc. You can just make a ‘grid controller’ actor and put all the code in there.

Regarding your compile error, I suspect you still have to level BP reference to it, which won’t work.

Just use GetActorOfClass to get a valid reference to your target point actor.

1 Like

Thanks ! That worked a gem!

Initially I couldn’t run the blueprint after making those changes. Only got to found out later that it was my game mode that was causing the blueprints to load incorrectly. So I had to temporarily switch the game mode back to default and only then ‘Begin Eventplay’ start to fire correctly at each actor blueprints.

1 Like