I am trying to work out a canvas to switch my playable character during the game. I have 2 main characters and what I want to do is switch characters at the press of a key, so 1 for char 1 and 2 for char 2 etc…
Obviously they need to keep the same position, rotation etc… I was thinking it might be as easy as just turning on and off renderers perhaps?
I think that would depend on
The complexity of your game. If
They switch just appearance your
Approach would be sufficient, I
Believe. However If your characters have
Already some properties, i.e. Power,
Health, color, height, etc that you want to persist, you might
Want to move them as well at switch
Hi Chocolade, thinking about it I don’t think my approach would be enough… perhaps a better way would be to copy components with values from one object to the other.
So i’m thinking, start with an object of each character, hide all but the start character then on the switch, copy the transform values and then all of it’s child components except for the renderer, enable the new and disable the old. Seems to work in my head, now how to put that in a canvas…
I would do a little bit different.
a) create a Main Character as parent with only a transform component
b) create a child game object attached to it with the other components, renderer, rigid body, etc
c) do the same for all characters, so they will have a parent and one child
d) Create a flow canvas with an input method for specific keyboard keys
e) at time of switch copy the complete child from one of the characters and set his parent as the Main character, then detach the child from the Main character