Trouble casting from one blueprint to another.

Hello guys,

I’m making a third person shooter and I’ve encountered some problems while trying to cast from one blueprint to another.
What I’m trying to do is get a vector 2D from the player camera (only available from the player blueprint) and send this data to the HUD blueprint, so i can center the ray casting from the camera with the crosshair in the HUD.

There is a picture of the blueprint I have set, and everytime I run it gives me a cast failed.
I’ve tried adding a delay of 2 seconds to the cast wondering if the problem was I was casting too early and the HUD blueprint wasn’t created yet, but nothing changed.

Thanks for your help!

Trouble may come from your reference. Do a “get player controller” / “get hud” to input your “cast to”. If there is always a cast fail check that you set your hud in gamemode (check world settings too).

Agree with Fen. Because your variable MyHudRef is already of type MyHud (as seen in the pink box) then there’s actually no reason to Cast it to a MyHud type. Where in the Event Graph are you setting the initial value of this? If you aren’t doing anything with this variable, then the the problem is you’re trying to cast “nothing” to MyHud which is causing the fail.

Firstly, thanks for your reply!

Secondly, the way Fen explained is 10x easier, and it worked, thanks!

1|2Hawk, I was never declaring it anywhere because I thought the simple fact of being a varialbe of type “myHUD” would be enough for it to locate the blueprint, but I now I see the error, as you explained.

Thanks again!