I’ve got a gender select screen and based on this data, in the next scene, the character controller has a model/avatar assigned to it.
During testing I dragged and dropped a model/avatar onto the controller (male or female) and everything worked fine. However, when I assign the model/avatar ‘on the fly’ it doesn’t work. The avatar just floats around.
I’m sure I’m missing something small but I don’t know what it could be. Any help would be appreciated.
CODE:
public GameObject MaleModel;
public Avatar MaleAvatar;
public GameObject FemaleModel;
public Avatar FemaleAvatar;
public GameObject Player;
GameObject model;
// Use this for initialization
void Start () {
int boy = PlayerPrefs.GetInt ("Gender");
if (boy != 0) {
model = Instantiate(MaleModel);
Player.GetComponent<Animator>().avatar = MaleAvatar;
} else {
model = Instantiate(FemaleModel);
Player.GetComponent<Animator>().avatar = FemaleAvatar;
}
model.transform.SetParent (Player.transform);
model.transform.localPosition = new Vector3 (0, 0, 0);
}