How I create global blueprint function ?

Yes I did that . I created an object reference in actor blueprint 1 but when I tried to use that reference variable in the widget blueprint I get error

The error is Accessed None trying to read property … ?

This is due to the fact that the reference variable does not initially point to a specific object of the specified class, but only allocates space for its storage in RAM. As you can see, the default value is none.


If the variable is inside an actor, and its type is also an actor (or a child class of an actor), then you can set the value by selecting a specific actor in the viewport using the detail panel by clicking on the actor.
By first setting the Instance Editable flag on the variable.

You can also use the Get Actor of Class function, but you need to somehow select which instance you need.


References for other objects (for example widgets) usually need to be saved after creation.


1 Like

Thanks I understand now.

About setting the default value for ref variable . After I created the ref variable and type = new blueprint 1 I placed a cube in the viewport and tried to set the default value but the combo box is disabled and also the arrow for “select actor in the view port” does nothing so what is wrong here ?

You need to pull out to the level the actor IN WHICH you want to set the value, and the one TO WHICH you want to refer.
You can set the default value only for those actors who are on the level (if we are talking about hard references (blue)).

But there are also soft reference (turquoise) in Unreal. Their value can be set directly in the blueprint, but the use must be resolved before use.

They differ in that the hard reference will change value when the object is deleted (the value will become None (nullptr)), but soft references continue to save the path to the object, and when it is loaded again, you can access it again using the old reference.

Hard references also ensure that the object they refer to will be in memory, and if necessary, Unreal will load it automatically, IF this is possible.
But for actors this is NOT possible, since their load is controlled by the level. When a level is loaded, all the actors on it are loaded.

Also, you will not be able to select an actor located on another sublevel using a hard reference. Because a situation may occur when the level is unloaded and the hard refrence is reset.
At runtime you can set the value via Get Actor of Class, but if the sublevel is unloaded, reference will be reset.

1 Like

Thanks alot I appreciate your help.


:bouquet: :bouquet: :bouquet: