Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Nemox · Jun 15, 2015 at 12:21 AM · networkingprefabspawnmanagerlobby

Player Prefab on Lobby Managers?

This question is pretty short and straightforward. When I use a regular Network Manager, set a Player Prefab in the Spawn Info, then start a game, the Online scene is loaded and the Player Prefab is spawned.

When I do the same thing with a Network Lobby Manager, the Player Prefab is not spawned.

I am highly confused by this. What is the intended use of the Player Prefab, and why doesn't it get spawned from a Lobby Manager?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image felsi · Jun 21, 2015 at 01:48 AM 0
Share

I try to do the same thing... According to the documentation, it should work that way, but the playerObjects are not getting spawned and OnLobbyServerSceneLoadedForPlayer is never called. autoCreatePlayer is true

avatar image felsi · Jun 24, 2015 at 03:38 PM 0
Share

$$anonymous$$y problem was, that i didn't mention to use OnStartLocalPlayer() ins$$anonymous$$d of OnStart() for the LobbyPlayer

avatar image Tinycrate · Aug 06, 2015 at 03:06 PM 0
Share

$$anonymous$$y problem got fixed too by overriding OnStartLocalPlayer() , not sure why this is working actually, you may try this out.

avatar image darthbator · Aug 30, 2015 at 06:14 PM 0
Share

I am having this exact same issue! OnLobbyServerSceneLoadedForPlayer but OnLobbyClientSceneChanged is! I noticed you both mentioned overriding OnStartLocalPlayer, where? On the lobby player or the game player? I have it overidden on both. However I also have normal Start logic on the player object. This has really been frustrating me. I'm in the process of downloading 5.1.3f in hopes this is some kind of bug that has been addressed.

5 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by darthbator · Sep 01, 2015 at 12:24 AM

So this is what fixed the issue for me

http://forum.unity3d.com/threads/lobbyplayer-to-gameplayer-networklobbymanager.349614/

Take at the above forum post. It looks both OnLobbyServerSceneLoadedForPlayer and OnLobbyServerCreateGamePlayer are called on the LobbyPlayer gameobject AFTER the scene has been transitioned to the "gameplay scene". So if you have not instructed untiy to not Destroy the gameobject on scene transition the above 2 methods will never be called. just DontDestroyOnLoad(gameObject); to the awake method of your LobbyPlayer (or inhereted) gameobject and everything will end up being called as expected.

*Remember Unity appears (does?) to Destroy objects recursively when a scene is loaded. So if you have your lobbyplayer childed to a mortal gameobject it will still be Destroyed in scene change even if you add the above line of code. Remember to unparent the lobbyplayer object before you perform any scene load to make sure it sticks around to do player spawning.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image M0rph3v5 · Nov 12, 2015 at 08:12 AM 0
Share

This is what happened for me as well, was using an UI Component for the LobbyPlayer object which I naturally parented to a canvas. The result was it being deleted and thus no spawning of player prefabs.

The lobby player component seems to handle the dontdestroyonload itself, but as you said if it's parented to a mortal object it dies anyway.

avatar image slackpipe · Apr 15, 2018 at 10:41 PM 0
Share

Unparenting is so obvious now. I was spawning the lobby player under the lobby manager and having it spawn a UI object to display information, which just created more headaches.

avatar image
1

Answer by Wojalin · Jun 30, 2016 at 05:10 PM

https://abrgame.blogspot.de/2016/01/using-unet-to-spawn-different-player.html?showComment=1467227533786

Try this and give the guy a cookie! Srsly! He deserves it!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by xristos1989 · Jun 22, 2015 at 03:42 PM

Have you tried adding the a lobby player prefab with the network lobby player component? In lobby manager you must set 2 prefabs.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by omgketchup · Dec 17, 2015 at 04:53 PM

I ran into a similar issue here. In my LobbyPlayer I had an OnLevelWasLoaded call, not marked as an override or anything. I first tried removing all the code in that function, no luck, but removing the function itself let the OnLobbyServerSceneLoadedForPlayer be called.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Mr-Jun · Oct 04, 2016 at 05:14 AM

The link provided by Wojalin is a great solution.
For those following it, the SetPlayerTypeLobby() function takes a NetworkConnection as an argument. You can pass this argument like so:

 LobbyManager.s_Singleton.SetPlayerTeamLobby(connectionToClient, index);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to fix OnObjSpawn netId: 1 has invalid asset Id when using Lobby example in existing project 0 Answers

Prevent NetworkLobbyManager from changing scenes. 2 Answers

Spawn Prefab inside another Prefab 0 Answers

UNET lazy loading, what does it mean? 1 Answer

OnStart ___ vs OnLobbyStart ___ methods from NetworkManager and NetworkLobbyManager 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges