Parent event called once instead from each instance

I have a class called BaseCharacter, that have 3 children, Player, Enemy, and NPC.

I fired a print function in the parent class in begin play event (BaseCharacter) and it only fired once just for the Player.
They all have instances in the level map.

MOST importantly, it used to work until I did an update to Unreal.

So if there are 3 instances of the same parent class, and in the parent class I’m printing in the begin play event, I need to have 3 prints (Player, Enemy, NPC), but I’m only getting once (all children conform to BeginPlay->ParentBeginPlay).

What could be the reason for that? because it works as expected in another project of mine.

I think in begin play you need to call parent begin play event (or other way around)
Just create empty actor, do some code in its begin play, then create inherited child
unreal will create those parent/child calls and you can see how it should be done.

Also are both projects same unreal version?

Yes, as I mentioned I did called parent begin play, but still the problem exist.

Very weird problem, this not how OOP works.

Some screenshots of the blueprint should help.

Normally this works like you suppose it should.
Maybe the inheritance is not setup correctly. Try to reparent your blueprints. Perhaps something is messed up there.

Furthermore be aware that some things are not necessarily initialized in the BeginPlay moment when using characters and pawns. Often the OnPoccess event is the correct one.

After further investigation, I realized that there is a CastTo node, that failed in the parent class,
which leads to this silly problem where the logic just didn’t finish so the children didn’t receive the events.

2 Things I learned, always do error handling and avoid using casting as much as possible.

1 Like

Why shouldn’t you avoid casting? Simply do sth accordingly when the cast fails.

The only difference between blueprints and c++ in this regard is that BPs don’t crash your game.

Adding a simple PrinString node with log entries is often enough to remind you that there is something wrong.