Page 1 of 1

Island demo player spawn

Posted: 25 Sep 2010, 00:11
by appels
Hi,

Why are remote players spawned at -1000 ?

Code: Select all

UnityEngine.Object remotePlayer = Instantiate(remotePlayerPrefab, new Vector3(-10000, -10000, -10000), new Quaternion(0,0,0,1));


The problem i have is that my player gets spawned at that position but stays there till it moves the fist time.
Instead of spawning at the spawnpoint.
There is also a remote that stays at that lacation when i'm connected, i have no idea why that is.
This also happens when only 1 player is connected.

Thanks.

Posted: 25 Sep 2010, 08:54
by ThomasLund
The player is spawned "out of sight".

As you can see a few lines further down, we then send a "force remote player to send me the real transform"

WHy?

Because if someone joins a game in the middle of it, none of the remote players will ever be at the spawn points. Suddenly popping in remote players into the world where others can see them and then moving them somewhere else is wrong.

The "force players to send their transform" command makes sure that remote clients send their current transform without having to move first

/Thomas

Posted: 25 Sep 2010, 18:49
by appels
ok but :

The "force players to send their transform" command makes sure that remote clients send their current transform without having to move first

i have this setup also ( took it from the island demo ) but it's not working.
any ideas ?

Posted: 25 Sep 2010, 18:54
by ThomasLund
Use an authoritative server setup instead? :-D

Might be a bugger in the logic somewhere. Poke me if you find it - especially if its also in the island demo, so it can be fixed

/T

Posted: 25 Sep 2010, 21:09
by appels
ok, i will play around with and see if i can find the issue.

Posted: 26 Sep 2010, 00:08
by appels
I found my problem :

Code: Select all

private void SpawnRemotePlayers() {
   SmartFoxClient client = NetworkController.GetClient();
   foreach (User user in client.GetActiveRoom().GetUserList().Values) {
      int id = user.GetId();
      if (id!=client.myUserId) SpawnRemotePlayer(user);
   }
}


Each time a player gets spawned, id!=client.myUserId is allways true.
So each player gets spawned 2 times. One stays at -1000 and the other one is moveable. I think i'm missing something. :)
It doesn't happen in the Island demo.