Custom Character Mesh Class
Overview Author: () In this wiki I show you how you can easily use your own custom Skeletal Mesh Component class with the UE4 ACharacter class! In the same way that you can easily change the UE4 Ch...
Overview
Author: ()
In this wiki I show you how you can easily use your own custom Skeletal Mesh Component class with the UE4 ACharacter class\!
In the same way that you can easily change the UE4 Character class to use a custom character movement component, without having to create your own character class from Pawn upward, you can also tell UE4 to use a custom character mesh class\!
This means that you can implement a custom Skeletal Mesh component with your ACharacter-extending-characters at any time during development\!
The only rule is that your custom USkeletalMeshComponent class must extend USkeletalMeshComponent as its base class
.cpp
In the constructor of your character, you specify your custom character mesh class:
//Custom Mesh Class!
AYourCharacter::AYourCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UYourMeshComp>(ACharacter::MeshComponentName))
{
Review
The only change to the regular UE4 constructor is this:
Super(ObjectInitializer.SetDefaultSubobjectClass<UYourMeshComp>(ACharacter::MeshComponentName))
You are telling UE4 to set a subobject class by name.
This name is set in Character.cpp
FName ACharacter::MeshComponentName(TEXT("CharacterMesh0"));
and used here:
Mesh = CreateOptionalDefaultSubobject(ACharacter::MeshComponentName);
Summary
Epic Engineers have made it very easy for you to customize the ACharacter class with your own custom Skeletal Mesh, Capsule, and Movement component classes\!
You dont have to rebuild characters from APawn to use custom components, just use the syntax shown above to tell UE4 to use your own custom component classes that derive from the base classes used by ACharacter\!
Enjoy\!
()