x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Change the SkeletalMesh of a Character class

I created a class deriving from the basic character class. I want to write a function to change its SkeletalMesh-Component.

Now I know there is a variable "Mesh" in the Base Character class which contains the information about the Characters mesh. But how do I change/swap this mesh? Thanks

Product Version: Not Selected
Tags:
more ▼

asked Sep 28 '14 at 10:09 AM in C++ Programming

avatar image

Pseudocorpus
426 38 47 143

avatar image Pseudocorpus Sep 29 '14 at 04:54 PM

when I do it like "Mesh->SkeletalMesh = New_Mesh" it doesen't change the mesh, but puts the old mesh in a t-pose position and cancels to play the idle animation.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Got it. The correct term is "Mesh->SetSkeletalMesh(New_Mesh);"

more ▼

answered Sep 29 '14 at 07:12 PM

avatar image

Pseudocorpus
426 38 47 143

avatar image SpaceEng Jan 12 '19 at 02:56 PM

Mesh is a private variable in ACharacter, how does that work?

avatar image Pseudocorpus Jan 12 '19 at 03:00 PM

Oh that was a long time ago. Back then "Mesh" was public. Now you have to do it like "GetMesh()->SetSkeletalMesh(New_Mesh);" ... I think

avatar image SpaceEng Jan 12 '19 at 03:58 PM

What is the proper way to load the mesh? The below doesn't work.

 static ConstructorHelpers::FObjectFinder New_Mesh(TEXT("SkeletalMesh'/Game/Mannequin/Character/Mesh/SK_Mannequin.SK_Mannequin'"));

I've seen references it's bad to hardcode asset references, but I don't understand how you could random or let the player select a new skin without this.

avatar image Pseudocorpus Jan 12 '19 at 08:47 PM

I think the Construction Helpers only work in the Constructor of a class.

It is bad practice to hardcode references to assets. In case you want to do it anyways write this in the constructor:

 static ConstructorHelpers::FObjectFinder<USkeletalMesh> Mesh_Male_FeetObj(TEXT("SkeletalMesh'/Game/Characters/BodyParts/Male_Feet_LOD_0.Male_Feet_LOD_0'"));
     if (Mesh_Male_FeetObj.Object != NULL)
         Mesh_Male_Feet = Mesh_Male_FeetObj.Object;

"Mesh_Male_Feet" is a USkeletalMesh-pointer (declared in the header).

You could also just make the USkeletalMesh-pointer and specify the asset in the blueprint... I guess this would be the "right" way to do.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question