- Home /
How to Change a character??
Hi, I think about a game that I can change the character by using an item, just like "if I eat meat my character becomes a dog" but this dog has his own movements and powers, a complete new character, so just change the meshfilter will not work, how can I do this??
Thanks!
Answer by Meltdown · Nov 24, 2010 at 05:44 AM
What you may want to try is simply keeping an array of GameObjects that your character can turn into.
So lets say you have 3 possible animals your character can change into.. Mouse, Cat and a Dog
You load the Mouse, Cat and Dog game objects. But you keep Cat and Dog invisible.
So if you start as a mouse, and you each cheese, you turn into a cat by either hiding the mouse object, and making visible the cat object with the new transforms the mouse had. Then do the same when the cat becomes the dog. Simply hide the cat object, and load/make visible the dog object with the transforms the cat had.
You might also want to look at Instantiate and Destroy methods on the Object class for more information on what is the most efficient way to do this.
But that way it will be messed, I think, because if each character walk in different speeds and have different powers (fly, walk, swim etc) with time they will be far away one of other.
You will only be controlling one character at once right? And you want your existing character to change in the same place to your new character??
What you can do just before change is set the position of your new character to the position of the old character, and then change it to that. Also you can set in code your character to active, or not active, and check for that, if character is not active, don't do any movement.
Your answer
Follow this Question
Related Questions
How to change characters with pressing a button 0 Answers
Changing player object UNET 1 Answer
how to change object 0 Answers
When Near Object, Change Scene 0 Answers
Activate Object with trigger and if leave then inactivate 2 Answers