I have the character generator example and have edited it so it works, however I have some confusion about the only part I was worried about. How do you get the pants to move with the legs, or shirt to move with the arms, etc? I don’t see that explained in the example
Ideally the clothes should be conformed to the figure PRIOR to exporting it to unity. At the very least the clothes need to be made specifically for a figure and has matching bones and needs to, well, like real clothes, fit the figure. If you have all of those things, then you can parent the bones of the clothes to the bones of the figure and the clothes should move. You can’t just take random clothes and parent them to a figure and expect it to automagically conform and re-size to fit. It’s a lot of work to hook separate clothes models to figure models in Unity and make them move. I guess if you have them with the EXACT same animations you could parent them to the figure and create a script to play the exact same animation at the exact same time, but if it ever gets out of sync, it will be obvious.
No, the best way is to create your character with all the clothes they will ever wear and just turn off the parts you don’t want showing. I’m pretty sure that is what the example does, but I haven’t looked at it in a few years, so I could be wrong.
Consdiering my modeling skill amounts to “What will Daz3d let me actually do” I can’t put thousands of clothes on someone and just turn them off. As for parenting bones, I’m not positive how that works, can you point me to an example?
I used Playmaker to do this so I don’t have any code I can share with you. There is a tutorial on 3d Buzz about conforming a ragdoll bone by bone so perhaps you can watch that and modify it.
I use DAZ figures myself so I know it works. Are you using DAZ figures for personal use or did you shell out big bucks for the game license? I was lucky and got in on super sale several years ago for half price.
I’m going to do a kickstarter once I have the game finished so I can do that, until then i don’t “need” the license. However, this playmaker could be useful too, i have clothes in Daz I can export, I just was hoping to not have bunches of the same model, since there’s no real need to. I mean if I’m going to do that I might as well be using 2d sprites, since I have to change the whole model to change a hat
Most hats are easy as there are no moving parts. You don’t need to go through all this for just hats (and hair for that matter). Export them with no joints and then you can parent them directly to the head in Unity. No need to worry about it bending with joints if it just sits on the head. They even work on just about any other humanoid, if you scale them a bit.
For clothes, I found it much easier to conform the clothes to a figure with all the body parts hidden first. This way there is no doubt that they match up and if you use outfits like I did (instead of individual clothes parts) it makes parenting much easier. Avoid gloves. Each finger bone needs to be parented!
edit: also, you can pile on as many clothes items in DAZ Studio as you want then then export it with ALL the clothes you’ll ever use already attached. Then in Unity it’s a fairly simple matter to turn them all off and turn on only the ones you want to see. The downside to this is it makes a huge file size.
Oh really, interesting, that will be most helpful, I’m building a “Party” game that will speak to all systems so I can fix the problem of being too big
I just found an issue: I found your tutorial and while everything is explained, it requires Ultimate Unwrap. I can’t afford Ultimate Unwrap, and the demo doesn’t save. So How do I set unity to turn off the clothes as needed without it?
Ultimate Unwrap is useful to combine the materials and cut down on draw calls but you can do without it. The process is more or less the same, just one fewer steps and less optimized results but it will still work. All I ever do in Ultimate Unwrap is to open it and save it and close it. No actual work is done there. You turn everything off in Unity, not Unwrap.
Oh ok then, so how do I do that? I’m alittle confused as to the steps enclosed…for the sake of argument say i wanted to render it only when i press F, what is the code to do that?
Is this the Character Customizer from Digitech Gamez? He has controls in the GUI to add / remove clothes.
I changed the source to use a much bigger library and was about to mod the GUI to look nice but I decided to wait for Fernando’s Character Generation system and make my only models for that system instead. It’s more flexible than the swapping out of entire meshes.
I also bought Chris West’s Mega-Fiers which has a nice DAZ demo in it to hedge my bets but that will cost you $150.
Pulling this out of thin air so it might need some work but here goes:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public Renderer hat;//drag the hat's renderer here
// Use this for initialization
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.F))
{
if(hat.enabled)hat.enabled=false;
else hat.enabled.true;
}
}
}
Put that code on the figure that has the hat and then find the hat in the hierarchy and make sure it has a renderer component and drag that to the hat variable in the code and now you can show and hide the hat with the f key. Hat is only a placeholder. Use any renderer you want.
If you have many hats here is the code for that:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public Renderer[] hats;//drag all the hats' renderers here
private int curHat;
// Use this for initialization
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.F))
{
hats[curHat].enabled=false;
curHat++;
if(curHat>hats.Length)curHat=0;
hats[curHat].enabled=true;
}
}
}
again, this will probably need some adjustments to work, but that is the very basic way to do this.
I’m probably not doing it right but how do I drag the renderer to mono? its all one object, and even if I open it up, select the geometry.shape file and drag it to mono, it doesn’t want to work.
You don’t. You drag it to the Inspector.
Ah ok, good this is working! (Well half way, I can turn the clothes off but not on, but that is just a tinkering thing) Most helpful and useful, thank you!