- Home /
Swap Character Controller based on Health
Title says it all. I am really knew to coding, but the Unity Cookie tutorials are helping me understand things. Think of it like Ghouls'n'Goblins where as you take hits you lose bits of armour. Well I want to make it so the character is limited in movement when he has all his armour on and when his armour is gone he can move alot.
I guess since I will be using different models with different sized collision detection I would have to write separate character controllers scripts for each model and have a script on an Empty Game object that swaps out said Models+Character Controller scripts? So i guess the question would be, how do I go about swapping out the different Models and character controllers.
I assume it would be an if statement based on the variable I set for the Health Points and a GetComponent for the scripts. But I am not sure how to swap the models.
Answer by nventimiglia · Jul 05, 2012 at 05:24 PM
Destroy the old player object, and instantiate the new player object in its place. I Personally would not go with the option.
Have a single controller with a 'speed' variable. Make both models a child of the controller object and switch between their visibility.
Answer by stingman · Jul 05, 2012 at 05:27 PM
You do not need to have different character controllers. You need to have one parent game object with a character controller and you can have several different meshes childed to that Parent Object. Depending on which mesh is active you then adjust speed accordingly to the parent object that has the character controller. The childed meshes do not need anything except a mesh renderer. Hope this helps get you started
Your answer
![](https://koobas.hobune.stream/wayback/20220613073744im_/https://answers.unity.com/themes/thub/images/avi.jpg)