Variable saved in parent not useable in child?

Hi,

I’m trying to acces a variable (a widget) that I save as reference in a parent class from within one of it’s child classes. But when I check the variable inside the child class it appears to be “none” (empty)
I’m trying to wrap my head around what’s going on here as I can’t see what I’m doing wrong exactly. But there must be a reason for this. Any idea why?

Here is where i save it inside the parent class

Here is how I try to use it in the child class

This is the error i’m getting

Now here comes the interesting part. I actually have 2 childs that need this variable. Now when I first tried to use it with one of them it worked! But the other child refused to work. So I simply unplugged the node of both childs and suddenly the first one didn’t work anymore either.
Now this only makes it that much harder to comprehend what is going on. I really hope someone can help me on this one. It’s melting my brain. :stuck_out_tongue:

Did you test that the parent class does really have a reference to it? Or is it None there aswell?

Did you possibly changed the variable to private?

My parent class has no instances in my scene. Is that why? I always thought that when you put a function inside a parent, it will just be executed everytime an instance of the blueprint is created, like a child of that class. Am I wrong here?

It is set to private yes. But when i put it to public it makes no difference. Why does it have to be public?

OMG I found it! Of course how could i be so stupid!!! The problem was that i had an event begin play in the childs as well. Which overrides the begin play from the parent. Haha!

Everything working as intended now. Sorry for my stupidity.

EDIT: One problem though. How can I still utilize the child’s begin play event without overriding the parent’s begin play? Is that even possible?

EDIT2: Found it! Trigger event "Begin Play" of parent class - Blueprint Visual Scripting - Unreal Engine Forums

1 Like