Spawning Players Already in a Room in Unity

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

User avatar
IdleChimp
Posts: 8
Joined: 19 Dec 2022, 01:00

Spawning Players Already in a Room in Unity

Postby IdleChimp » 20 Feb 2023, 18:05

So, I notice:

Room.UserList

and

SFS.UserManager.GetUserList()

I'm firing a method to loop through and create the players after joining a Room of course.

But neither of the above are being consistent for me. When I join a room I need to Instantiate all the players who have already joined that room. UserEnter and UserExit work fine--but, for the life of me I can't get all the users that are already there, to spawn in.

Any posts or advice on this?

Thanks!
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Spawning Players Already in a Room in Unity

Postby Lapo » 21 Feb 2023, 09:46

Hi,
those two lists are not the same thing:

  • Room.GetUserList() returns all users in the Room(*)
  • SFS.UserManager.GetUserList() gives all the Users that you're currently able to interact with, in case you're joined in multiple Rooms.
(*) = keep in mind that if the Room in question is of type MMORoom then the UserList is strictly based on the AoI. In other words the Room might contain 100s or 1000s of other clients, but you're only aware of those falling in your AoI.

for the life of me I can't get all the users that are already there, to spawn in.

Seems very strange as we have no reports of this, nor we've ever seen it.
Can you provide a repro-case so that we can check it out?
Also please specify the SFS2X version and client API version in use.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
IdleChimp
Posts: 8
Joined: 19 Dec 2022, 01:00

Re: Spawning Players Already in a Room in Unity

Postby IdleChimp » 18 Mar 2023, 16:48

So,

The problem was simple. I had a coroutine that waited for all the users to instantiate and then "showed" them.

Like one second or so, just enough time to give Unity to load them. But for some reason, the weren't visible in Game Mode. I switched over to the Editor view out of Game Mode and noticed a bunch of Collision Wire Frames where the players were. So, they were there! Just not visible yet.

Had nothing to do with the player count!

I used Room.GetUserList() since I need all the players in that single room. But, thanks for explaining that Lapo. That information was
useful!

Everything on this front is fine now.


Thanks,
Idle Chimp
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Spawning Players Already in a Room in Unity

Postby Lapo » 19 Mar 2023, 14:27

Thanks for the update :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 16 guests