So long story short, I’ve set up a character customization widget that works for the most part. I click the buttons, side panels open up to change the various options (which aren’t all set up yet but since it’s mostly material swapping I figured this is more than enough to work with).
My problem lies in…the fact that I don’t know how to actually apply to changed material onto the player character once the game begins. It seems to revert back to the default material everytime. I’ve tried making a variable with “save game” enabled to force this change and have Beginplay on the level set the skeletal mesh’s material to be that variable’s material but it didn’t work. So I need help figuring this one out…
The options show it properly and the button is clickable and it will reflect the change on the dummy I set up just fine.
Here’s what the setup for the button looks like currently. I know this one’s screwed up but as mentioned I had tried to fix it by casting to player character and changing it’s mesh material there, as well as trying to do it with a forced variable updating the material at the start of the level. Neither method worked, so I clearly don’t know enough to make this properly work. Help fixing this is greatly appreciated!
Edit: So this setup here shows the changes to the player character, but only on the Customization level and it doesn’t seem to keep them into the next level despite it being tied to a saved variable.
Hm, well everything’s already on the character like that so could make child for changing the colors in that way yes. But like…there’s a lot of stuff depending on the base one currently so I was hoping to literally just swap it’s materials. It works in the customization level just fine, but just doesn’t work anywhere else. Making children of the 3P character would sadly require a complete rework of every system because they all call the parent one as it is which wouldn’t work for the children if they’re what’s controlled by the character. (But I have no idea tbh…I’m just looking for a very simple color swap with the least amount of potential issues from it)
I’ve been able to change the mesh and material of objects on the character throughout the levels too so I believe it’s possible to just change the material of it but idk how to make it work. For the other thing I have a “pick up” system where she can pick up stuff in her mouth and carry it around. Based on what’s picked up, the default mesh/material swaps to the object she picked up. This also saves, allowing her to drop the object she picked up with no issues at all. I just need something like that to be honest where clicking the button will just save the different material onto the character skeletal mesh so it will work between different maps too. And if I have to somehow recreate the process where it changes her material every level that’s fine too so long as it works. Just the method I used for the collectible does not seem to work for the 3P_Character bp.
Are you using 2 materials?
Because you get the player character - set material (what should be set here?)
Then you get the class and set the material of the class.
I think it would be enough if you get the actor and set the material of the actor.
Eventually i’ll try it and upload some screenshots for you
Yeah see that’s what I thought too but it doesn’t seem to keep persistance between levels. The moment it enters another level the changes are reverted to the BP’s defaults. And even putting the materials that are changing into a custom event to be called upon each level’s start, it still don’t change it.
As for why you see 2 materials there, one is to show the change on the dummy the player sees during customization. The other is for the player character but it only seems to change the materials for that current level and once it’s loaded for next level doesn’t have the changes as the first set of screenshots show. It will 100% change the 3P_Character’s mesh materials in that level, but no others. Using “get actor of class” for the 3P_Character bp doesn’t save the changes either as that was the second method I tried, which woulda been the same way the collectible object handles it and it works fine for that.
I have to be doing this wrong somehow…I know not every customization in a ue game will just go and make a bunch of child BP’s for simply changing the hair color, it would be sooooo many in many of those games making the amount of data far larger for it. I don’t see that as the way they do it so there has to be a way that works x.x that method would for my game alone require, 23 child for the base combinations of eye/body color, another 60 for the combinations of mixing them with ease. That’d be absurd lol so I know there’s definitely some way to get this working.
This is on the 3P_Character bp. Not sure if it being anywhere else would make it work either. But it gets the player character mesh, and literally changes the eyes and body materials based on the variables that set those. This is why I’m very confused because this has worked on other things just fine. (the second set material is actually on index 1 but not in the screenshot.)
I assume you are not setting the new character right.
get the player character, change the mesh material
get the character class and Set the mesh material
cast to the characterBP and set the material
I would try to get the class only (skip step 1 and 3), set the material and assign it then to the player
Btw within your set color function, you are setting the material for the same index. I think body or eye should be 0 and the other one should be 1. (depending in how many slots you have)
Hm, well the “Set colors” event is called once the level is loaded. Which this is already getting the character BP since it has to get the event from that to change the materials. The event takes the mesh directly from the 3P_character and then sets material for both the body and the eyes (screenshot show the index before I fixed it so shows as same but it’s 0 and 1 respectively). Being as this event is directly on the bp I need the materials to swap for, I would think it would work this way but it just doesn’t change anything. This leaves me to believe the variable for the materials is the problem if it’s not recording the new materials from the previous level it’s just using the defaults.
I can’t cast to the 3P_Character in that since it is itself. I could get a self target variable thing but don’t see how that’d be any different than getting the mesh directly like in the screenshot above. I have tried to do so with the “get player character” method and doing it that way both at the start of a new level and within the setup function itself on the customization level. Neither worked or changed anything. I also tried it with just get actor of class 3P_character. Same results it did nothing and kept the defaults.
I really do think it’s a variable issue but idk. I’m very new to Unreal Engine developing so I’m rather clueless as to how to do most things beyond the basics. I can design landscapes though! lol
So here’s what I changed and this method seems to work by storing the info for the body material in the Game Instance which makes perfect sense now that I think about it lol.
Then I have it set to simply call on the game instance when the level begins play and it has the variable saved so it works when having the 3P_Character swap material using that variable. So I think it’s all fixed now, ty so much for the help with this!
One slight problem though lol, the Eye material for EyeType1, which is a rounded (not so dragon dragon eye lol) doesn’t seem to want to let me use the material for it as a material variable. Any idea on this one how to fix that so I can use that material as the variable’s value? It’s set up exactly the same, but for some reason I can’t drag/drop that material into the value of the variable…It’s a material instance btw. But so is the body material and that one is now working perfectly as intended x3. I’m not sure why it won’t accept the material as its value.
To show what I mean, there’s just no results to set it to the ones I need. None of these below show as something that I can set into that variable. Any idea how to fix this one?
Is “MAT_LDM_Realistic” the material which is currently assigned to the mesh?
Because then it would be setted through the assignment.
Therefor you have to set the eye-material manually like so:
There you can set the Material. (Please keep in mind that you set the material at the correct place within your code. Mine is just an example)
It’s two different materials. I reckon I could try to do it similar way as the body but instead of a direct variable maybe get the character and cast to BP and just change it there if it’ll work. Not sure how to set it up but can try some ideas later today and see if I can manage to get it working like that.
But yeah the default one on index 1 is MI_Eye_Realistic_Round_Blue material. It just doesn’t set it to a material variable like the body works with for some reason. I’ll try what you suggested there and see if it’ll work with that and a saved variable to determine which to switch it to.