Change USkeletalMesh to UPoseableMesh in C++
In simple words, my aim is to simply change USkeletalMeshComponent into UPoseableMeshComponent. I need it to do in C++, not in BP.
Here I use First Person C++ Template and change code of
and MyProjectCharacter.cpp file:
Unfortunately it's not as simple as it might seem. That modification creates errors, that I can't solve with my knowledge.
I'll be very grateful for your help.
asked Jan 09 '19 at 01:40 PM in C++ Programming
What you're trying to do won't work the way you've been trying to go about it.
Taking things back a step, it appears you're trying to make a custom pawn actor that works like the ACharacter class but uses a poseable mesh instead of a skeletal mesh. Part of the problem is, the ACharacter class has its own USkeletalMeshComponent built in to it, which means if you derive your custom pawn from ACharacter, your subclass is going to have a USkeletalMeshComponent by default.
You're probably going to need to disable the ACharacter's USkeletalMeshComponent so you can add a UPoseableMeshComponent in its place.
To do that, you're going to need to use the FObjectInitializer, along with the DoNotCreateDefaultSubobject function, in the constructor for your custom character class. Here's how your updated constructor would look in your .cpp file:
That will prevent the character's default USkeletalMeshComponent from being created when your actor is constructed.
Now you just need to add back in your desired UPoseableMeshComponent, much like you were already doing. Define your UPoseableMeshComponent in your header file:
And then put something like this in your updated constructor:
(Like I said, you already had this part figured out, so it should look familiar.)
With that, your custom character should have a poseable mesh component instead of its default skeletal mesh component.
Of course, you can also add back in your getter functions as desired.
Hopefully this gets you closer to a working solution!
answered Jan 09 '19 at 05:15 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here