Page 1 of 1

switching character at runtime with smartfox scripts

Posted: 19 Oct 2010, 13:05
by appels
Hi,

I'm trying to find a way to switch the current character to another one at runtime.
What i tried so far is :

spawn the localplayer with the 2 characters and disable the renderer on 1 of them and then switch the renderer on when needed. But i don't think thats the right way to handle it.
I also tried to destroy the localplayer and then instantiate the new one but when i call a destroy, it doesn't seem to work as expected. Even after destroying all the components on the gameObject. ( have to call the destroy multiple times to have all destroyed)
The character has also the scripts for the smartfox connection and i'm not sure if i have to do anything for those.
Maybe reinitialize the connection ? just a guess...
Also... how would i handle the remote players ?
Anyway... if someone could push me in the right direction, that would be awesome
Thanks.

Posted: 20 Oct 2010, 07:38
by ThomasLund
I would move the character itself one level down in the hierachy. Move network scripts up to a "top parent node for the given player", and then you can swap the player model itself without destroying the scripts (and thus potentially loosing your connection)

/Thomas

Posted: 20 Oct 2010, 10:52
by appels
Great idea, thanks :)