Casting to another BP fails no matter what

What I am trying to do:

I have a setup inside of BP_FirstPersonCharacter, where if the player presses the keyboard button Y, Unreal should cast to another BP called SwitchToGardenAreaBP, and return the value of a variable stored in that BP, which is a boolean named ‘Is Character Colliding’.

BP_FirstPersonCharacter:

SwitchToGardenAreaBP:

As you can see in the screenshots, parent of SwitchToGardenAreaBP is Actor, so I created a reference to it within BP_FirstPersonCharacter. SwitchToGardenAreaBP already exists in the game, and I exposed the Actor reference and selected in the viewport so Unreal knows which actor I am referring to. But not matter what, cast fails.

If I create a direct reference to SwitchToGardenAreaBP, then I get the error of ‘Accessed None Trying to Read Property’. The work around was so far, using ‘Get All Actor Of Classes’ node, which works flawlessly, but it seems like creating hard references could be taxing so I do not want to rely on this work around and want to understand why my casting fails in the first place. I’d appreciate it, if anybody can explain why this is happening.

Try to print string the value of your variable ParentClassActorReference and also print the object name of your instance SwitchToGardenAreaBP , to see if they match.

Thank you for your reply @Arodi007. This setup (Parent Class Actor Reference > Get Object Name > Print String) prints ‘None’, as value.

And this setup just prints ‘SwitchToGardenAreaBP’ as expected. So it seems like there’s a problem with my reference but I still can not point out what it is.

If I create a direct reference to ‘SwitchToGardenAreaBP’ instead of creating a reference to the parent ‘Actor’, I also get ‘None’ as value, strangely.

Note: I can not access to the value of my ‘Is Character Colliding’ boolean within my BP_FirstPersonCharacter so I can’t check it’s value, if I understood your instructions correctly. It throws me that ‘Accessed none trying to read property…’ error.

Indeed that strange, from my side it working fine when printing it when i manually select my actor from the right panel in the editor.
Both my bp character and garden are in the level map.


If that still not work, you might want to change alternative to an OverlapEvent and using interface.

Our setup is completely the same and yet, my version doesn’t work for some reason. Regardless, I appreciate you taking your time to help me. What are the chances that my project is bugged/corrupted somehow?

You’re not selecting the Actor from the Level here. But the Blueprint Asset from the Content Browser.

image

To actually select the actor from the level, you need to mark the variable as Instance Editable in it’s Details Panel. Then select the Actor from the Level.

Hey Arjun. Thank you for your reply. The variable was already set to ‘Instance Editable’ and selected in the level in the first place, and yet still could not be accessed.


For some reason the reference of your garden is getting lost when hitting play.

What if you hit play button, then select your character bp from your outliner, and then set it actor=garden directly ingame (in PIE mode).

Also try it on a new project, it most likely a missing step, i doubt it a corrupt project but who knows.

How are you setting the variable from the looks all your doing is making bp variable of that type and then trying to cast to it, if you actually haven’t assigned the. Also you really should be using tags or interfaces for this sort of behavior your current implementation seems really taxing for what you are doing. Another thing to try is get all actors of class in begin play and print how many are found if none then i would start looking how you have setup your actor class and see if its not set to private or protected