Get variable value from parent blueprint

Hi! I want to get my Int value from the parent actor blueprint, but every time I try to get the Int value in the Child BP, I get its default value of 0, which is different from what I get from the parent. Here are the Parent and the Child BP that I use.

Child Actor

I don’t know why I get the default value, any help would be appreciated!

It’s because Parent’s BeginPlay is not executed; You need to call it in your Child BP. Right click on Event BeginPlay and select “Add Call to Parent Function”.
image

3 Likes

it seems in that specific case, run parents begin play would cause an infinite loop (beginplay–>spawn)

2 Likes

Aah, yes, I missed that. Of course.
However, the spawned child actor and the parent actor that spawns it are not connected. If one actor spawns another, it does not make it its parent. The spawned child is an independent instance, and its parent’s Int is 0.
Is setting Int and spawning a child is the only purpose of the parent, you don’t need it in the level at all. Just place a Child Actor in the level, and remove the Spawn node.

3 Likes

Aren’t they connected even if the Child BP’s parent is the “Parent” BP?

Screenshot 2022-05-20 164135

I thought, it is, because I can get the variables from the parent BP, I just can’t get its runtime values only its default value.

The parent has other purposes also, I just simplified the blueprint, so I can show my problem easier.

1 Like

It’s parent class, not parent actor. These two actors that you end up having in the level are absolutely independent of each other.

Everything you have in your parent class can be accessible and executed in child class.

I can get the variables from the parent BP

Yes, because default values are the same in the child class. When you get them, you get them from the default parent class, not from the actor in the level.

1 Like