Hello I’m a newbie into the Unity3D world. I have a question and hope someone can help. Does anyone know about changing a character to another character in C#?
I’m trying to make my game where you are the zombie player and you run up to human people (Ai Spawners) and when you touch them they turn into a zombie. The Ai’s change and become the same type of character as the player character. That’s the concept I’m trying to create and having an issue with.
One way you could go about it, would be the same way that simple destructible objects are done.
Have a script checking for a collision or trigger event involving a zombie/human, and when that event is detected, create an instance of the zombie game object, and destroy the human game object.
I’d suggest taking a look at SHATTER / DESTRUCTION in Unity (Tutorial) - YouTube to see how you can replace one object with another.
I don’t know if its the best way to solve this problem but the way that i would have approached this problem is -
You need a game object that contains all your custom components (Scripts) that you have on your character and make it as parent of your models. This way all you have to do is switch between the model on and off and all your functionality still remains on your player.
If however, once the human becomes the zombie and you need different functionality for you zombie guy , you can modularize your code accordingly and attach the unique functionalities to specific character gameObjects.
Hope it helps you…
Thank you so much guys. I’m going to try both ways. The concept I want to do is much harder than I thought. I’m sure I will do good with your advice. Thanks.