Download

Overriding parent events in child BP class

So I just learned I can extend a BP with a child class however in the EventGraph it comes up completely blank. Is there any way to view the parent graph within the child and make small tweaks and/or override certain events while leaving the rest(basic oop principles)?

I tried a simple example with a OnOverlap event in the parent and then a OnOverlap event in the child BP however it seems to execute the parents graph on the event.

Hey tiggus,

Can you provide a little more information on your setup? I just setup two blueprints (one is the child of the other) and added OnHit, OnBeginOverlap, and even Input keys in both Parent and Child and in all cases the Child’s version of the event took priority. I was also able to make a setup where I could switch between using the parent or child event in the child’s Eventgraph.

Let us know what your setup looks like and we’ll help you figure out the roadblock!

Sure thing, I think I may have figured it out after playing with it some more. If I copy and paste from parent into child graph then the event never fires on my child and it behaves the same as parent. In this case I am moving the object on overlap either in the Z plane or X plane for purposes of testing. If I create the overlap event node fresh in the child graph then it behaves as expected and translates properly along the Z axis.

Screenshots attached showing what the two graphs look like if I copy and paste the nodes from parent to child and then simply change the vector offset. This does not seem to work.

https://www.gamingproject.net/public/parent_bp.png

https://www.gamingproject.net/public/child_bp.png

Now that I know to create the event in the child by hand I am ok here but was wondering if the copy and paste method for BP’s is verboten or I am misunderstanding something.

Thanks!

Unfortunately, there’s not a way to override events bound to components in child blueprints. However, if it’s a normal event not associated with a component (events without a component in parenthesis after the title), you can call directly to the parent by right clicking on the event in the child, and selecting “Add call to parent”. When you copy/pasted the event from the parent to the child, what it did was actually make a new custom event (you can tell by the yellow “Custom Event” text under the title). That means you could call that event, but it’s not automatically hooked up for you. We do this so that if you’re moving lots of code between blueprints, you can see how things were hooked up previously, and it makes refactoring a bit easier.

In the future, there are some changes happening that will allow you to do this more directly. However, for the moment, it’s best to add a new function or custom event that you call directly from the event. So, in your case, you’d have your OnComponentBeginOverlap call directly to a new function you create (e.g. “DoStuff”), and then override DoStuff in your child blueprint. That will give you the flexibility you want, but working within the current system.

Hope that clarifies things a bit!

Thank you, it does!

Put the code in the parent class into a function and pass the necessary variables as arguments such as ‘other actor’. In the childclass, override this function. Doing this, the parent overlap event will be triggered but the child class function will be called since the parent function was overridden.