I can’t seem to get this to work. what am I doing wrong? The goal is to make it so that my character switches with model is active but thats not working, it seems that none of the models are being set to the list, and also that the default model is not being set as true.
charController=gameObject.GetComponent(CharacterController);* ` If anymore info is needed ask away, I omitted the code where I set up the arrays but its pretty straight forward.
function SelectCharacter(num: int){ // select character[num]
for(var j:int=0; j < charList.length; j++){
var character: GameObject = charList[j].object;
if (j == num){ // if the object is the one you're looking for...
character.SetActiveRecursively(true); // activate it...
currentChar = character; // and save it in currentChar
} else { // but if is another character...
character.SetActiveRecursively(false); // deactivate it.
}
}
currentCharID = num;
// get the CharacterController of the selected character
charController = currentChar.GetComponent(CharacterController);
}
The way you was doing that before seemed wrong because in the last line you were getting the CharacterController from the object which had that script, but I suspect you actually wanted the selected character’s controller.