x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Referencing Blueprint Within Another Blueprint Issue

So I will try to explain this the best I can but when answering or considering my question please keep in mind I am an extreme beginner. I will also attempt to use pictures to explain what I am doing. I know a lot of you are probably very experienced and will likely know a better or alternate method of doing what I am attempting to do but what I want to do is figure out why this is not working. Even if it will NEVER work, I don't know why that is and I would like to know.

So all that being said here is the issue:

I recently learned that within a blueprint, like a UMG widget blueprint, you could create a reference to another a blueprint pretty easily, even an actor. All you have to do is click add variable, search for the blueprint, and then create an object reference of it. I was pretty stoked! This meant I could access the variables in another blueprint, and even potentially (I thought) change them!

So I created my reference to the blueprint, an actor with a single boolean variable inside of it, inside of a widget umg blueprint. This boolean would then determine the text of that umg widget. Specifically the widget has one line of text, and if the boolean was true or false it would set a text variable that a text element within the umg was bound to. SO, all that being said and done, before even getting to binding, when I call the actor reference and then from that GET the boolean value, the value is always false. Even if I set within the actor itself the boolean value to true it will always come back false.

I don't know why this is and I am very confused. A reference is not a copy, it's specifically pointing at the actor blueprint that I am 'referencing', and it should be able (and clearly seems) to be able to see that boolean value in there. And yet despite all this it's always returning the wrong value. See attached image for my spaghetti code.

Like I said please try to contain yourselves, I know you are all very smart people (no sarcasm, seriously) but I am trying to figure out this one small problem and like I said if it's completely wrong I'd like to know that. Then you can absolutely blast me with an alternative method :D. Spaget

A quick edit: I just wanted to clarify that yes my actor exists in the game world, I've compiled, saved, and set pretty much every variable I could think of to public.

Product Version: UE 4.19
Tags:
more ▼

asked Apr 04 '18 at 12:00 AM in Blueprint Scripting

avatar image

SerWind
1 1 4 5

avatar image Nebula Games Inc Apr 04 '18 at 02:59 AM

Yea I think @ThompsonN13 is right. I don't see anywhere that this variable actually got "set" to a specific instance. If you create a variable and in the details panel simply set it to the actor you want it will have all the variables contained within that actor, BUT it does not actually reference anything in game, there is no created instance so you can't do anything with the variables contained within. However, setting the variable to true and compiling should at the very least return a "true" value reading out of any reference I would think. Finally, not sure if this is by design but when you run this code it should ALWAYS be true, there really isn't any excuse why you wouldn't get it to print the true value as it is set up in the screen shot, essentially the reference variable boolean has nothing to do with this code and the branch is set to "true" so if that won't give you a true output you have some other issue hidden away.

avatar image SerWind Apr 04 '18 at 03:39 AM

How do I go about setting that then? Also yeah sorry I had it set to always print out true there just to try some different things.

I tried casting to get it but the casting fails, so I guess I am not doing that properly. I do at least understand now what I was doing wrong but now I am really curious how to properly set something like that up at the simplest level.

avatar image ThompsonN13 Apr 04 '18 at 03:45 AM

where are you creating the widget? and what is the actor that your trying to get a reference to? is the actor the player, a scene object, a enemy? also is the actor in the scene at runtime or is it spawned in at some point?

heres a few node that can help get you started. the first one is a basic way to set a variable in a widget.

theres a ton of ways to get the actor from within a blueprint by using casts and overlaps and things.

alt text

capture.png (134.6 kB)
avatar image SerWind Apr 04 '18 at 05:05 AM

What I had was an empty actor blueprint with the actor dragged into the scene. That actor had a variable, the boolean, and also created the first widget. The first widget then asks a yes or no question, and it's suppose to set the boolean inside of the actor. That widget then creates a second widget which is suppose to be able to see that boolean.

I know this makes no sense in terms of efficiency but I was just messing around to get familiar with interacting with different blueprints from within other blueprints.

So I suppose what I should do is get all actors of class (and get my actor), then assign the return value of that to the reference inside of the first widget? Does that make sense?

avatar image gk0r Apr 04 '18 at 02:34 PM

Re: I recently learned that within a blueprint, like a UMG widget blueprint, you could create a reference to another a blueprint pretty easily, even an actor. All you have to do is click add variable, search for the blueprint, and then create an object reference of it. I was pretty stoked!

You misunderstood how it works, you're not even close. If you want to understand how Blueprint communication works, watch this training stream - it is very informative. Official documentation on this subject is also excellent - I spent quite some time reading it when I was learning UE4. Make sure you read this bit too. There are more links on that page that explain Direct Communication and Event Dispatchers.

After you watch and read all of that material, let me know if you still have a real world problem (please do not try to 'simplify it' - it will not help either of us).

avatar image SerWind Apr 05 '18 at 12:59 AM

These were all amazing links. It's funny because I had asked this question multiple times before, a year or so ago, on multiple communities including this one, and the only answer I ever got for how to have two blueprints interact was the "Get all actors of" node. I'm guessing this can't be entirely new functionality, so I suppose I just got lucky.

That being said I think this question is definitely answered. If I have any further trouble with blueprint communication I will make another question. Thank you guys so much for your help.

avatar image ThompsonN13 Apr 04 '18 at 03:51 PM

thats definitely not the time to use a get all actors of class. if the actor is creating the widget just use the first method shown in the picture i posted above. basically when you create the widget you can drag odd the return pin which is a reference to that widget and from there you can set the variable to the actor by using a reference to self.

i reposted the same setup below so its more clear. you could also replace the actor type variable here with your bool and just set that value directly instead of having to deal with a reference.

alt text

capture.png (83.5 kB)
avatar image SerWind Apr 04 '18 at 06:10 PM

(don't worry gk0r I am going to respond to you too) Holy SMOKES that actually worked. I did not know you could drag off a widget creation node like that and set a variable within it. That's actually amazing. I cannot thank you enough for your seriously clear and very neat blueprints, and descriptions. I really need to start using node redirects more. Thank you!

And like gk0r said I really need to read the documentation on blueprint interaction and watch that video, clearly. I had watched a bit of a tutorial on making a UMG inventory but when I saw I could make a reference to a blueprint within a blueprint I figured I had struck gold. Ignoring the documentation: never a good thing. Thank you to everyone here who gave answers and contributed.

If I have further problems understanding it I assure you I will bug you guys :D

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

how are you are actually setting the reference? since your working from the widget it makes things a little more complex on how to set the reference. your going to need to set the reference either when the widget is created or sometime during runtime. i cant tell for sure but im guessing that you just set the actor variable to the type of the class your looking to reference.

more ▼

answered Apr 04 '18 at 12:20 AM

avatar image

ThompsonN13
10.4k 34 10 27

avatar image SerWind Apr 04 '18 at 12:57 AM

Doesn't creating the variable and choosing the actor set the reference? Or... am I just creating a variable that CAN contain a reference of that type? Maybe that's where I am getting hooked up... I tried casting it once but it said it was already of that type or something along those lines. Unfortunately I can't open the editor right now so I can't get pictures.

avatar image ThompsonN13 Apr 04 '18 at 03:10 AM

if you just selected the variable and went to the details panel and set the type to your actor type then that isnt set to a specific instance of that actor. so say you had a character in the level that you actually meant to reference then just setting the variable type wouldnt accomplish what your looking to do. you would need to get the specific character and set the value of the variable to it. its kinda like saying ok the actor im gonna reference is of this type but never actually telling it which specific one you want to look at.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question