Download

Code working in parent class and one child, but not the second?

I am so confused. I have 3 classes; a parent class of hoverbike_master and then two children, hoverbike_player and hoverbike_ai. I had some code for calculating the player’s progress along a spline inside the player class and it was working perfectly. I realized, however, that I needed that code to run on my AI as well so I moved it from the player class into the parent. Now when I test the code, I can see it working on the ai child class, but for whatever reason, it doesn’t work on the player. There are 7 ai bikes and the player spawned when I play the game, but only 7 print strings are added to the game. I didn’t think this was possible. If it’s working on the ai, then it means it’s working on the parent and should therefore also work on the other child (player) does it not? I’m not even casting to a specific class or anything so there’s no reason the code should be skipping the player.

Here’s my code:

Any ideas?

Oh strange. I think I figured out the issue. I had the GetRaceProgress event firing on an event timer inside the parent class and for some reason that wasn’t translating over to the children. As soon as I moved it over to call that specific GetRaceProgress node from the timer inside each of the children it fixed the issue. Is this expected behavior? You’re not supposed to call the event from within the parent?

If you do this:

The child will not print because it overrides the event. If you remove the event from the child graph, the child will print because it’s no longer overriding.


If you want to override but also want the parent do its thing first:

Now the child will Print.

Got it. I didn’t realize calling the tick in the child was considered overriding the parent. Would explain why that happened then.
Thanks Everynone :slight_smile: