Trying to share actor reference variable with other blueprints, no success

Hey all–I’m only a week into blueprint so I may be missing something obvious, but I’ve watched a ton of videos and haven’t figured out how to solve this–

My player controller, X1Alpha, is able to select a target actor from the game world and, supposedly, store it as a public variable:
MUHheSA.jpg

But when I try to get that variable in other blueprints (for example here, the HUD, so I can draw a reticle over the target, or the anim blueprint, so the player can look at the target) I get stuff like this:
3ad157e18e9e489634c9c748b8a087edb34a8f8a.jpeg

Googling the specific compile error didn’t get me very far. What am I doing wrong here?

You need a reference for your cast. In this case, you can right click and do “get player pawn”, then connect that to your cast to X1Alpha, in the Object field. That’ll take care of that error.

However, you’re making a few fundamental mistakes here (I don’t mean that in a mean way, just to help). Your cast has execution pins, and things are only “done” on execution pins. You don’t have anything connected to the casts input or output, which means you’re never telling the game to actually do this, so nothing will happen even once the error is fixed. You need to figure out when you want to call this - On Begin Play for example (probably not since this will be after you click an actor) - and what to do with the data. Because even once you get the data, your ConvertWorldLocationToScreenLocation isn’t actually doing anything. It’ll be getting the data and making the conversion, but nothing is done with the result. You need to drag off Screen Location and then do whatever it is you’re trying to do with your actor.

Moving back to the cast and the execution pins. You can right click your Cast to X1Alpha and click “convert to impure cast”. This will get rid of the execution pins so it’s data only, but you’ll still need to do your action after the convertworldlocation with some execution. I hope that makes sense.

So to fix your problem, right click, get player pawn. Drag that into the Object Input of your Cast To X1Alpha. Then, right click the cast, and click Convert to Impure Cast.

This will get rid of your errors and issues, then you can draw your retical from the Screen Location output of the convert.

Let me know if you need more help :slight_smile:

You’ve done it!

f92b74b25c2771a7612217d93d69c109557590ca.jpeg

Thanks so much for the help! I knew about the execution pins but not about pure/impure casts. I was trying to plug “get player controller” in before with no luck but “get player pawn” works great. :slight_smile: