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"

Trouble reffering to variables/blueprints between blueprints/mycharacter

Hey guys!

The last few days I've been struggling hard with making the easiest thing possible which is:

Reading out a variable from one blueprint in the other and use this to trigger something else.

You'd say this is the easiest thing ever! Just make an object variable with the blueprint you want to target and get/set like in the basic tutorial but every time I do that I get the error the variable is empty even though it's a bool. I feel like I'm missing something really easy which nobody talks about due to it being so obvious but I don't see it!

So obviously I do something wrong! I've tried my hand in casting but get the same issues none the less. I've googled around and found people with similar problems but the projects and the solutions were either out of context or too complicated for me to grasp so what I hope to achieve with this questions is that somebody can help me on the most basic way possible so I can continue. I don't need to make very efficient scripting so if there is a simpler way but less nice please use that. Once I grasp the basics I can go deeper.

So how do I make the following work in the easiest way possible without me getting the error that the variable is empty? This should be a piece of cake for you guys but for me it somehow doesn't work and it frustrates me to no end!

I have a box in the room (basic blueprint with box mesh and nothing else in it's components) and my player character that comes standard with the project. My project is a blueprint project and the rest of the room is empty but the floor. The box prints out the status of a bool I set in my character.

Mycharacter Blueprint:

I press Q to trigger the set of a bool I named TestRef (it toggles via a flipflop) which is editable

Box Blueprint:

I made a variable called TestRef (also editable) that is an object linked to the MyCharacter_C blueprint and made an event tick that prints out the status of the bool via get TestRef(blue) -> Get TestRef(red) -> Convert to String -> Print

If I press play it prints out false but keeps doing that even if I press Q numerous times. Closing down the play it gives me the error:

"Error Accessed None 'TestRef' from node Construction Script in blueprint Box"

Or in other words it's probably empty and not defined. But how do I do this?

Any help is much apreciated as it's very frustrating being able to make more complicating stuff but not being able to make the simplest of the simple happen!

Product Version: Not Selected
Tags:
more ▼

asked Nov 11 '14 at 02:03 PM in Blueprint Scripting

avatar image

StrawberryHusky
1 1 3

avatar image Adam Davis STAFF Nov 11 '14 at 03:26 PM

Hi StrawberryHusky,

Can you post a screenshot of your blueprints? I might be able to see what is occurring.

avatar image StrawberryHusky Nov 11 '14 at 04:32 PM

Thanks for the reply! Here are some screens. I just feel so dumb for not being able to do this haha. Hope the pics work! It's all made in an empty bleuprint first person project so it's all clean otherwise.

World: alt text MyChar BP: alt text Box BP: alt text

world.png (825.8 kB)
mychar.png (237.0 kB)
boxbp.png (210.9 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Can you show/tell where/how you set the value of the TestBox::TestRef variable? Presumably that's where the problem is - it's not correctly hooked up to the current instance of the MyCharacter class.

more ▼

answered Nov 11 '14 at 04:48 PM

avatar image

Xenome
2.1k 64 54 120

avatar image StrawberryHusky Nov 11 '14 at 04:52 PM

I'm not sure I understand, I'm pretty sure that that's exactly where the issue is but I'm not sure I understand what it means.

avatar image Xenome Nov 11 '14 at 05:15 PM

I mean that the TestRef variable in your TestBox class is probably set to the correct type (i.e. a MyCharacter object reference) but possibly not assigned the correct value (i.e. an actual reference to the instance of MyCharacter that's in use when the game runs). So, TestRef effectively doesn't reference anything useful when you hit play.

If you want to continue on the plan you currently have, you could probably store the correct reference in your TestBox class by setting up something like:

EventBeginPlay->GetPlayerCharacter->CastToMyCharacter->Set TestRef to that reference

...and things should (theoretically) be all nice and peachy!

avatar image StrawberryHusky Nov 11 '14 at 06:08 PM

Wow thanks! This is exactly the stuff I've been missing all this time as nobody really shows you actually have to set variables beforehand as well. For a programmer this maybe really logical but for a designer like me it's not.

Thanks for sticking with me and my inability to see these things and helping me out! I'm going to mark this one solved for now, I think I got enough to keep digging deeper! Thanks again!

(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