Island demo player spawn

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

Moderators: Lapo, Bax

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

Island demo player spawn

Postby appels » 25 Sep 2010, 00:11

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

Postby ThomasLund » 25 Sep 2010, 08:54

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

Postby appels » 25 Sep 2010, 18:49

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

Postby ThomasLund » 25 Sep 2010, 18:54

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

Postby appels » 25 Sep 2010, 21:09

ok, i will play around with and see if i can find the issue.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 26 Sep 2010, 00:08

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.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 1 guest