Are there plans to add the ability to override virtual functions in Blueprint?

This would be an enormously useful feature, and one of the few things preventing me from coding my entire project in Blueprint (along with the inability to make actor component classes). I’ve been using C++ for something around a decade, but Blueprints compile much faster and are easier to debug. For now I’ll continue to use C++ in order to prevent implementing things in hackish ways. Has anything been said about adding such a feature? Thanks!

I am not a programmer, but I am curious what overriding a virtual function would do and how that would work.

As an extremely basic example, it would do something like this…

Let’s say you have an actor class called Base_Pickup_Class.

When it is ‘collected’ on one inherited version of the class, a function would be called which would do something.
For ease of explanation, lets say it was something visual like spawning a particle effect.

In another inherited version of the class, the same function would be called when it was collected.
However a different action would happen, for example a decal would spawn on the ground.

So you could have 3 classes…
Base_Pickup_Class, and inherited from that, Particle_Pickup_Class, and Decal_Pickup_Class.

I’m almost certain you can already do this with custom events, or blueprint interfaces.
But since i’ve been waiting for some software to arrive i haven’t really had a chance to check specifics.

So you want the function in the parent class, and you want the children to be able to use it to different effects?

Couldn’t you just have a general function that has different endings in each of the children?

Parent: Item Collected, then do X.
Child 1: When X called, do Y.
Child 2: When X called, do Z.

From watching the blueprint communication tutorials lately I think that would be handled by interfaces and custom events like you said. Unless Daggerbot has run into something that can’t be handled like that. I would love to hear about it! :slight_smile:

You can flag a C++ function as BlueprintNativeEvent, which means you can have C++ implementation, but can override it in a derived BP. In 4.2 we expose CanJump in Character like this.

So just to confirm (as of 4.7) there is still no way to accomplish the use of a virtual method if both parent and child classes are blueprints? If we want to override any methods we must create the default implementation in a parent C++ class as a BlueprintNativeEvent and then must override it in the child class blueprint?

There is only one by default which is CanJump Override, other than that you need to do it in C++ which isn’t too hard. I know almost nothing about it and managed to create my own CharacterMovementComponent and override many of its physics function.

But I understand what you are asking, you want to create a function on a parent blueprint and be able to override it in a child which you would think should be possible but isn’t

It is possible! In fact all Blueprint functions that return a value can be overridden by derived Blueprints.

Create an Output for your function (and hit the “Pure” bool if you want a pure virtual function i guess) in your baseclass:

Create a child class of that BP and go to function, there should be a button called “override”. Hit it and select your function:

Is that what you want to do?

Note, you can override functions that don’t return a value as well, but they’ll show up in the event graph instead of the functions list IIRC. All functions introduced in Blueprints are implicitly virtual.

Michael Noland

Thanks for the info (:

PS: “Noland” reminds me of One Piece. :smiley:

I just noticed in the 4.8 Preview there are now SEVERAL Override Function too, but CanJump override is gone. I didn’t investigate that so I might still be there in some form

Ahh, It all makes since now almost two months later. So all Blueprint functions are virtual by definition. Good to know.