switching character at runtime with smartfox scripts

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

switching character at runtime with smartfox scripts

Postby appels » 19 Oct 2010, 13:05

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.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 20 Oct 2010, 07:38

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
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 20 Oct 2010, 10:52

Great idea, thanks :)

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 2 guests