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"

unable to change value of a variable from one blueprint in another

Ialt text am unable to change the value in one blueprint so across blueprints but in another below should be some photos. but then when i'm in the level and I press the [y] key it gives me the errors below.

alt text

Product Version: Not Selected
cap12.jpg (68.4 kB)
cap14.jpg (59.8 kB)
more ▼

asked Dec 09 '14 at 02:22 AM in Blueprint Scripting

avatar image

121 21 31 39

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

3 answers: sort voted first

Check these:

  1. Make sure the variable 'Character HUD' is valid is points to an instance. Use the 'IsValid' node for this.

  2. Instead of setting the variable, try printing out its value to see if you can actually access it.

PS: I personally think that Character HUD is pointing to None (ie it is not pointing a valid object)

more ▼

answered Dec 09 '14 at 03:10 AM

avatar image

3.4k 154 52 272

avatar image connormurry Dec 09 '14 at 03:11 AM

charachter hud is an variable object that points to the actual blueprint named charachter hud

avatar image connormurry Dec 09 '14 at 03:17 AM

and when i tried the things you suggested i still get this error alt textalt text

cap15.jpg (156.1 kB)
cap16.jpg (20.7 kB)
avatar image ScottSpadea Dec 09 '14 at 04:16 AM

you need to check IsValid before the printString node, because that print string grabs data from your reference variable without checking it, which means it might be a null pointer, and if you never set it, than it definitely is a null pointer.

avatar image mindfane Dec 09 '14 at 05:33 AM

Did you use IsValid node before trying to access the variable? Also you need to assign a valid reference to an object to the 'Character HUD' variable. ie simply creating the variabale and setting its type wont make it work. At some point you manually need to 'Set' the value of 'Character HUD'. Only then can you use it.

avatar image connormurry Dec 09 '14 at 10:45 PM

i still dont know what you mean by setting the reference and im not changing the value of charachter hud im getting a variable from that BLUEPRINT and trying to change its value

avatar image ScottSpadea Dec 09 '14 at 11:17 PM

the photo you attached as part of your question uses a set function. you were setting an integer. setting an object pointer or setting a reference is the same thing. an object reference is the light blue variable type. its like an integer or a string, you have to set its value to something in order to use it.

avatar image connormurry Dec 10 '14 at 12:09 AM

OK but i don't get what i have to do to fix this the object variable 'Character HUD' is a object of the blueprint 'Character HUD' and it points to 'Character HUD_C'

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

you should always use IsValid to check object references/pointers before using its data or functions. and if the reference is invalid, maybe that is a good time to try to set the reference. alt text

alt text

more ▼

answered Dec 09 '14 at 04:26 AM

avatar image

9.6k 320 205 450

avatar image connormurry Dec 09 '14 at 04:36 AM

i still dont understand what do you mean???!!! and what do you mean by set the reference?!

avatar image connormurry Dec 09 '14 at 10:28 PM

okay well i got this when using the is valid function so here alt text

cap18.jpg (124.2 kB)
avatar image connormurry Dec 09 '14 at 10:32 PM

and i just switched it up a little and added this little snipit before everything else alt text

cap19.jpg (146.6 kB)
avatar image ScottSpadea Dec 09 '14 at 10:47 PM

thats still wrong. your printString node references a variable from ControllerHUD, so the exec input connecting to the print string should be connected to the IsValid output. you are still accessing potentially null reference variables.

avatar image connormurry Dec 09 '14 at 10:50 PM

YOU ARE NOT GETTING WHAT IS GOING ON! i am not trying to print the value of battery charge level when the object is valid i want it to print it out no matter what so now when it prints it out its zero so when it does read the variable it will print 100 so i know its working

avatar image connormurry Dec 09 '14 at 10:50 PM

and what do you mean by REFERENCE VARIABLES??????!!!!!!!!!!!?!?!?!?

avatar image ScottSpadea Dec 09 '14 at 11:13 PM

reference variables store the memory address of an object. they are the light blue variables.

avatar image connormurry Dec 10 '14 at 03:55 AM

was that really so hard to say sorry if im frustrating you but it is hard to understand you

avatar image connormurry Dec 09 '14 at 11:00 PM


avatar image ScottSpadea Dec 09 '14 at 11:01 PM

your error says access none, that means your reference is Null or Empty. references are the same thing as the light blue pin variables in the graphs, and it is the same thing as a c++ pointer, these blue pin objects need to be checked using IsValid. IsValid checks if pointers are null. if they are null, you cant access their data because they don't point to any data. you need to assign your variable/pointer/reference/bluethingy, and to do that, you use the set function. alt text

avatar image connormurry Dec 10 '14 at 03:54 AM

can you please be more specific i dont understand are you talking about 'Battery Charge Level'? or the charachter HUD object variable how how would i use the "set function" for this?

avatar image ScottSpadea Dec 10 '14 at 05:04 AM

alt text

avatar image mindfane Dec 10 '14 at 06:02 AM

^ This is the right solution.

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


Have you gone through the Blueprint tutorial videos posted by Epic in youtube? If not, then please go through it. Also it looks like you don't have much programming experience. Even though you can do blueprints without serious coding skills, you must have some basic understanding of how stuff work

This is the tutorial: https://www.youtube.com/playlist?list=PLZlv_N0_O1gbYMYfhhdzfW1tUV4jU0YxH

How ever you keep asking what REFERENCE is. I will try to explain it here:

When you are working with blueprints, a reference is not much different from a normal variable (Integer, Floats, Vector..). But when you switch over to a programming language like C++ they are entirely different. So if you are working with Blueprints only, you dont need to worry too much about it. In most cases, when we say 'reference' we only mean an instance of a Blueprint.

So in your case, you have a variable named 'Character HUD' of type 'Character HUD_C'. Now this only means that the variable 'Charcter HUD' can store and instance of 'Character HUD_C' blueprint. It DOES NOT automatically create an instance and point to it. That is your job. Before you can use the variable 'Character HUD' and access any member variables, you first need to make an instance of 'Character HUD_C' and Assign (Set) it to 'Character HUD' variable. Until you do this, the variable 'Character HUD_C' is empty (aka Null/None), ie it is not usable. This is where IsValid comes into play. IsValid is used to make sure the variable you access is actually usable.

So in your case to solve the issue, this is what you will have to do:

If the default HUD class for your game mode is 'Character HUD_C', then you should get a reference to your HUD using 'Get HUD' node and assign the returned value to 'Character HUD' variable. Ideally this should happen within 'Begin Play' event.

On the other hand, you are manually instantiating 'Character HUD_C', you should do ti within 'Begin Play' and assign the created instance to the variable 'Character HUD'

more ▼

answered Dec 10 '14 at 04:31 AM

avatar image

3.4k 154 52 272

avatar image connormurry Dec 10 '14 at 08:40 PM

thank-you for finally explining this! Mind fane! But I have a question I don't think I can assign a variable to the character HUD blueprint and I don't understand why it took this long just to explain this to me.

avatar image mindfane Dec 11 '14 at 05:45 AM

If 'Character HUD' is your HUD class (which you have set in your Game mode), then you dont need to store it in a variable. You can access it anytime by doing 'Get Player Controller->Get HUD'. Also if you want to store it to your variable, you first need to cast it to 'Character HUD' (ie the output of Get HUD is of type HUD,and you need to cast it to the proper class)

avatar image connormurry Dec 11 '14 at 05:57 AM

how would i set it as the HUD class? i am using the widget blueprint for the HUD

avatar image connormurry Dec 11 '14 at 03:29 PM

Can someone just tell me how I would get a variable from another blueprint that's not in the level, is not an object, and is used like with a widget blueprint where I can get its value and change it, trigger animations, and so fourth. I am starting to regret using unreal engine for my game because of the amount of difficulty I have had to go through just to try and get this solved and no one has a manged to help me solve this entirely. I thank you guys help! When I needed help you guys were there and prompted swiftly but I mean come on I have had this problem now for nearly 10 days and no one has managed to explain it properly to me

avatar image mindfane Dec 11 '14 at 03:46 PM

I am sorry that you are not able to figure out a solution.

From my experience, I can assure you that UE4 is the easiest engines out there. Blueprints are extremely easy as long as you understand the basic concepts. It is no different than a scripting language like javascript or unreal script. Thats why I said if you have programming experience, you will find it very easy.

While its true that Blueprints allow non-programmers to write game logic very quickly, you will still need to understand the basic concepts of programming such as variables, references, classes, members, inheritance.. I don't know how good your programming skills are. But I strongly recommend you to go through the youtube tutorials. If you are still having issues, the wikis and forums have plenty of tutorials on different subjects like networking, UMG, Animation..

Try going through them patiently and I am sure you will get the hang of it.

PS: Form what I've understood from your comments, I think you need to concentrate on Classes, inheritance and casting.

Good Luck

avatar image connormurry Dec 11 '14 at 03:50 PM

I mean I have a pretty expansive knowledge on proGramm ingredients I have dabbled in Java currently learning advanced c++ and I have played with lua. But I mean I have trouble figuring problems out with out explicit instructions I have a very hard time getting answers out of abstract answers

avatar image connormurry Dec 11 '14 at 03:51 PM

But I mean if you could please provide some tutorial videos I'll gladly watch them ili just don't know where to start

(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