Casting and referencing blueprints does not work

I have tried everything and it is extremely annoying


Screenshot 2022-08-01 195417

Hi there,
It looks you’re getting a “soft reference” (green variable) and converting to a cast input (blue “object”). How and when do you set this Reticle Widget REF before triggering these nodes?

its on soft reference because i tried everything and stopped there. I put it to Reticle Object Reference Variable before, and it did nothing.

The above question still stands. How do you obtain the reference? Creating a variable to hold a reference does little on its own, you still need to tell which object you’d like to refer to. How do you set the value of Reticle Widget REF?

If done correctly it’s quite likely you wouldn’t even need to cast - as the blue NOTE on the cast node suggests. Direct communication does exactly that - grants access to the object of the correctly type so you could call DeFocus.


Soft references serve a different purpose.

If all else fails consider describing what the end goal here is. From the gameplay’s perspective.

1 Like

I create a variable, then set its type as Reticle Widget Object Reference. Then i rename it to Reticle Widget Ref

This does nothing. The editor does not know which object you mean. Imagine you created a string variable to hold text but forgot to type in the text. That’s what you have here. An empty variable, so to speak.

Screenshot 2022-08-02 093414

then why does the reference even exist

A pointer can point to nothing. A dangling pointer. A dangerous thing. Think of it as of reserved space.

so then how am i supposed to call events through bps if the only evident thing (to me) is useless

We need to reference it correctly. You say you want this reference to point at a widget - where do you create this widget? At some point you might have created one with a node:

image

Or you’re using a widget component? How does the reticle get to the Viewport?


So I’m assuming you want me to make a variable from the return value. That makes sense. Although I don’t understand why references exist in the first place and how to do this across physical actors

image

Promote the return. Now you have a valid reference, and the type will set automatically, too! If what you posted happens in the same actor as this:

You’re ready to go, no need to cast.

thanks! but the question still remains, how do i reference anything that i havent created

If you haven’t created it, it does not exist. If it does not exist, you can’t reference it.

But you do create it dynamically with the node.

even if it was placed in the level??? then how do i set it if its in a level

Actors placed in the level are instantiated and do exist, you can reference them easily in the Level Blueprint. But communicating with the LB is a royal pain the neck.

Where else do you want to reference something that was placed in the scene? And why? Not the radicle surely.

for example, if i were to reference a button when it was hit with a linetrace, do i drag off of “other actor”?

That is the reference of the actor that was hit:

Or

image

The other actor this actor overlapped. Yes. But a button is unlikely to be an actor - it would be a widget. Unless it’s a big physical button made with a mesh (like in Quake) - that could be an actor.

for example, if i were to reference a button when it was hit with a linetrace, do i drag off of “other actor”?

I meant physical button. Thanks!

this thread is confusing a bit because they are saying you need to use the normal blue color Object Reference not the light blue Soft Object Reference. This will ensure that your blueprint will find the object.

create a blue normal variable. then in begin play use the Construct Object from Class node unreal and set ti to the same class as the variable is. The Reticle. Then from this node output assign it to your variable so you keep track of this object.

The light blue is a different thing. Is just a link, like a web address link. It is used to load objects at runtime from the game data.

It will fail the cast because you are trying to cast to basically a piece of text. The way to use these soft object light blue things is to load them using Load Async which needs one of these soft reference links