Inherit blueprint character in c++ class

Hi guys,

I’m UE4 noob. I created a Character with its animation and movement on blueprint. Then I want to create a class on C++ based on this blueprint. Is it possible? If possible, could please let me know how?

Here what I did:

  1. Create and setup a blueprint character
  2. ‘Add code to project’ based on blueprint character class
  3. On World Settings, Game mode, I change my Default Pawn Class to the new generated character class
  4. To make sure it works, I use GEngine to output some text, but it didn’t work and no mesh nor movement.

Thank you in advance for your help and guide.

I dont know what you did, but you cant create C++ class based of blueprint class as its not exist during c++ compilation. So your C++ class needs to be base for blueprint class.

Thank you for your answer. I created a new Character class and make the existing blueprint inherit to the C++ class.
Then I just set my Character Physics properties on the class.

Thanks

Hi BatavianIsmail,

It sounds as though you may have been doing the process in reverse of how it should be done. If you want to have a custom class for your Character, then you will want to create the C++ class first. You will most likely derive from the existing Character class from the template you started with so that your character includes all of the default character behaviors and components. Then you can add your own customized behavior and components to the class in code.

After your custom character class has been created, you will then go back into the Editor and create a new Blueprint deriving from your custom character class. You will still need to make sure to tell the Gamemode that you want to use your custom character Blueprint.

You don’t have to use code though. It is possible to just create a new Blueprint that derives from the default character class and set up your custom behavior entirely within the Blueprint. That choice is up to you.

Yes . I created the blueprint first, then I realized that I need to override some methods, then I decide to ‘Add code to Project’. I use my blueprint as parent class for my new Character class. And I forgot that it won’t affect anything to my Blueprint. Then I created a new Character Class, and have my blueprint inherit to the new class. And it worked.
Thank you for your clear explanation. It helps me get deeper understanding.

Cheers!