Hey everyone! I have a small minimap blueprint setup that works great, but I put it together mostly by trial and error, and now I’m trying to actually understand how it works under the hood.
So, the core question: Why does the Cast to node update dynamically in this blueprint even though it’s apparently called only once?
Context: I have two data sources for this minimap: a character parent blueprint (which tells whose transform to read) and a vehicle parent blueprint (which provides the current vehicle speed).
The Car Speed For Map variable exists exclusively in the parent blueprint BP_VehicleCore, so I can’t pull it directly from WhoIsController because WhoIsController changes dynamically and isn’t always a BP_VehicleCore. Using Get Actor of Class (BP_VehicleCore) doesn’t work either, because BP_VehicleCore itself doesn’t exist directly in the game world—it’s just a parent class for vehicles. So Get Actor of Class grabs the very first child it finds, and in this case, Car Speed For Map always equals 0. Because of that, I ended up using Cast to.
Once I hooked it up, everything worked, and I was stoked! But right after, I realized I don’t fully get why the Cast to acts dynamically (i.e., as WhoIsController updates, the Cast To stops failing and starts returning True), even though the Cast to node itself seems to be triggered only once.
I’d really appreciate it if someone could break this down for me. I try to avoid just throwing nodes around blindly, and Cast to is an awesome tool—especially when you actually know what you’re doing with it.
Hi, in order to help you I’ll need to understand first you’re trying to get. What does the function WhoIsController returns you excactly ?
And to partially answer your question, if the Cast is giving you different result is because you’re giving it different material to work with. The Who Is Controller function is returning you different results, one of which can’t be cast as a BP_VehiculeCore.
Hey! Thanks a lot for taking the time to look into this, I really appreciate it.
WhoIsController is a variable inside the main player blueprint. It can hold two potential values:
A reference from BP_CharacterCore pointing to itself. Essentially meaning: “The player is currently controlling me right now,” so the minimap “tracks” the player.
Upon interacting with a vehicle via a blueprint interface and a raycast, the raycast result overwrites the WhoIsController variable, essentially saying: “Now the player is controlling the vehicle,” passing a reference to that specific vehicle so the minimap starts “tracking” it instead.
Your previous breakdown completely matches how the blueprint is behaving right now (at one point the player blueprint doesn’t match the cast, and at another point—right after the raycast—it suddenly starts matching).
My core misunderstanding comes down to this: the Cast to node is only called once, so in my head, even when WhoIsController changes, nothing new should happen. The cast happened once and isn’t continuously comparing WhoIsController anymore. Yet, in practice, it feels like the cast is sitting on an Event Tick and reacting dynamically. That’s the exact part I’m struggling to wrap my head around.
When you cast to a class then set the return as a variable (in this case bp_vehicle link), whenever you access the var later you have access to its vars and components in real time because the blue actor variable is a hard reference, or a direct pointer to where the actor lives in memory. Cast ->> Set: actor variable is like writing down someone’s phone number, and Get: actor variable is like calling them. When you call them with get you can ask them where they are (or whatever) regardless of where they were when you wrote down the number with cast.