Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by niocy · Nov 30, 2017 at 04:51 AM · gameobjectnetworkingnetworkclientclient-server

[Unet] NetworkServer can not assign local player authority after a scene change

Hello. So my problem is like the question states.

  1. I use NetworkManager and have inherited the class.

  2. I have a Custom Scenecontroller which tells the local client to send a message to server that the client has loaded. Everytime the game loads a scene, a prefab with networkbehaviour will be spawned. This prefab has a PlayerController class, which holds commands for basic data.

  3. My networkmanager offline scene is the basic fill info and connect scene. Online scene is a lobby where you choose your team. Third scene, which is not included in networkmanager, is the game scene.

  4. I have noticed that when the server uses NetworkServer.ServerChangeScene to load a third scene, in this situation it is the Game scene in which fighting and so on happens, I have to call NetworkServer.AddPlayerForConnection to re assign a gameobject for the player. In this particular moment everything works fine, a prefab with isLocalClient checked will be spawned and I am happy.

  5. But when I use a command from that playercontroller in the gamescene(3rd) scene, it fails to set local player authority. IsLocalPlayer is always false and playerControllerId is -1.

  6. tldr: In a third scene with networkmanager, spawning a playerobject to represent player in the battlefield using a Networkserver.SpawnWithClientAuthority doesnt work. PlayerController is only a helper class to help find needed functions and variables.

[Command] public void CmdSpawnPlayer() { TryToSpawnPlayer(); }

 void TryToSpawnPlayer()
 {
     if (!NetworkServer.active) return;

     Vector3 start = new Vector3(14, 6, 20.3f);
     GameObject go = Instantiate(PrefabController.instance.GetPrefabFromDictionary("InGamePlayer"), start, Quaternion.identity);
     NetworkServer.SpawnWithClientAuthority(go, connectionToClient);
 }

I have tried DontDestroyOnLoad on every playercontroller object, but same result. The third scene just doesnt give player authority. No errors are displayed.

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

147 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 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 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 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 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

NetworkBehaviour.isClient problems 1 Answer

How to watch in client applications what it is happening in the server one? 0 Answers

Very Confused on Networking HLAPI Practices 1 Answer

Since switching to using offline & online scenes in the NetworkManager, Clients will not sync (UNET) 0 Answers

Unity Network, smooth interaction between client and server player objects 0 Answers


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