Share code between blueprint classes

Is it possible to share the exact same set of functions between classes? I have two fighting player characters whos parent classes are characters.

I’d like them to both have the same code of double jumping/ wall jumping…
How do I make them have the same code?

Then create your own base class from Character class which has common code for all your characters. Strange as you seem to be aware of class inherency, or you don’t know that Character class has common code for all characters which also has Pawn code and Pawn has common Actor code.

In case of unrelated classes, they can’t have common code, but they can be related with interface, which obligates 2 or more classes to have same set of functions and they can also be contained in same type under interface.

“In case of unrelated classes, they can’t have common code, but they can be related with interface, which obligates 2 or more classes to have same set of functions and they can also be contained in same type under interface.”

Sometimes it’s also possible to move common functionality into a custom component class.

Yea you right, components are like actor plugins, it’s also a way :slight_smile: But obviuesly it works only with actors and you won’t have common type (but you can work around it by trying to find specific component in actor or even interface)

You can also use blueprint function libraries for things that might need to be reused that aren’t class specific.

Indeed, but you can produce a lot nicer looking blueprint that operates on object by doing that outside static functions. In static functions (which blueprint function libraries essentially is) you need to get object, inside specific type you don’t need to plug anything to Target pins. But i won’t deny it’s a valid option :slight_smile:

Ok, so lets say I have a bp class with parent class character that i name defaultfighter. I put in all the code that i want all future fighting characters to have. Then i want to create two classes with names fightingCharA and fightingCharB. How do u get FightingCharA and B to have all the code of the defaultfighter class plus some more. How do I do that?

Then if i would edit defaultfighter class it would edit tue code associated with defaultfighter in fightingCharA and B…

When you create new blueprint editor asks which class to use as parent, it shows simplifed window with few classes, to see all classes there checkbox on the right-upper corner, it opens class tree viewer where you pick parent class (go Actor->Pawn->Character and there should be all character classes).

You can laso easily create blueprint from class, from Class Viewer (Window->Devlopment Tools->Class Viewer) , which is superior way to view classes then “Content Viewer” either C++ or Blueprint for UE4 it all the same. You right click class there and there hsould be oiption to make blueprint class.

You can reparent existing blueprint you cna do that from Blueprint Settings (not sure the name, if you ever used interfaces is that menu you add interfaces in too)

I know how to create the class and set it’s parent. I’m just unsure how to have a blueprint classes children be the same as its parent, and when you edit parent code it would auto-edit child code.

Not exacly, in technical sense child class code overlaps the parent class code and child can override sected functions and events of child code.

Think of it this way when you create blueprint from parent, it has all the code of parent and it will act the same as parent if you place it on the level, all varables and functions you made in parent is accessable to child as well as if you have event in parent you can override that event and it will work diffrenly, you can call parent event on override too so you can extend parent code (you can do that by right clicking event and “call parent… something”.). In general you extending the parent class with child class

Not only that if you speak about Character class, it is a child of Pawn so it got Pawn code too (minus code that been overrided) and all core code of Actor as Pawn is a child of Actor, as well as Object (which is not so accessable in blueprint) because Actor is child of Object. It’s core of object oriented programming.

Here watch the video that i made about object and classes, i showed inherence there:


  1. Create parent class
  2. Create as many children class as needed
  3. Children class will auto-inherit all code from parent, despite not displaying it (variables too)
  4. Parent events can be called through the child and overwritten
  5. Variable can be overwritten too.