Access SkeletalMaterial at Runtime

Hello to my UE4 friends!

So, I’ve been working on a character creation screen for a bit now and I’ve accomplished a lot! One thing I’m having an issue with is allowing players to choose their skin tone.

How can I use the node CreateDynamicMaterialInstance off of a SkeletalMesh (object reference variable), rather than a SkeletalMeshComponent?

To elaborate I’ve made a video which you can see here:

I have a lot of my dev questions unlisted, so if the video doesn’t play here then you can open the link in a new window and it should show up fine on YouTube.

Thank you for your time. :slight_smile:

Here’s what I have going on after I try to get that Dynamic Material Instance, with no results.

Still working on it! But here’s a bump. :slight_smile:

So I have been able to do:

SkeletalMesh(Object Reference)>Materials>Get(with index set to 1)>Break SkeletalMaterial (Material Slot Name output node to print string and Material Instance output node to CreateDynamicMaterialInstanc)>Set Return Value output node of CreateDynamicMaterialInstance to a variable titled MIDLegsSkinTone.

The print string DOES print Element 1 from my Skeletal Mesh Object References Material Slot Name (in this case M_Player_Body)! So that’s good! I have found how to access that Material-ish…

But now if I use that variable (MIDLegsSkinTone) to adjust any Parameter Values, nothing happens. Just to note, when I’m done using play-in-editor or PIE, I don’t get any errors. :S

1 Like

So rather than trying this setup, I’ve taken a step back and decided to only use the Skeletal Mesh Components I have set on my PlayerCharacter.

In order to change skin tone, hair color and such I’ve used the SetMaterialbyName node.
PlayerCharacterReference>SkeletalMeshComponent>SetMaterialbyName.
Then in Blender I went back and altered my skeletal meshes to all have the same Material Slot Name wherever there’s skin.
That way, no matter what mesh is showing on… say… the Torso Skeletal Mesh Component, so long as there’s a Material Slot Name like “M_Player_Skin” then it will reflect the correct chosen skin tone.

That way I can add equipment, and if there’s skin showing on that skeletal mesh, it will reflect the players’ chosen skin tone.
I’ll post a photo of what I’m talking about tomorrow as a comment on this answer.

Sometimes you just have to keep experimenting and taking breaks so that your mind can tinker on the problem. :slight_smile:

2 Likes