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 ODINKONG · Oct 16, 2015 at 10:49 PM · networkingspawnunity 5.2

SpawnWithClientAuthority Player object is not a Player

I am trying to use the new features in 5.2 that allow for client authority spawning. I am getting some errors on the client that I can't figure out.

Here is the function

 public void makeBoosterItem (Vector3 pos, float temp, int biome){
             float Level = Vector3.Distance (pos, spawnPoint);
             GameObject Hr = Instantiate (healthRoot) as GameObject;
             Hr.transform.position = pos;
             Hr.GetComponent<Item> ().setNetworkOwner (player);
             Hr.GetComponent<Item> ().setLevel (Level);
             NetworkServer.SpawnWithClientAuthority (Hr,player);
 }

Now I garentee you that the player is the correct player. I have checked the network owner varible in my other script and it is the correct game object. However whenever I log on as the client I get this error SpawnWithClientAuthority Player object is not a Player. Its referring to the last line of that function. I don't understand. I am giving it a player object. It works on the server fine. Does anyone know more about the restrictions involved when using SpawnWithClientAuthority? does it have to be used from the player object? I can't find the documentation on the function.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by sharat · Oct 16, 2015 at 11:36 PM

The extra restrictions/easy mistakes for using SpawnWithClientAuthority() from my experience are:

  • You must run this code on the Server. Check if NetworkServer.active is true.

  • The prefab for the item specified still needs to be included in the NetworkManager list of spawnPrefabs. You can either add it to the list directly in the editor or dynamically via ClientScene.RegisterPrefab()

  • The object should have local player authority set to true.

  • You have to pass in the object instantiated on the server to the function, not the prefab.

  • I think that the player needs to have been set to ready first. But I haven't really tested this one.

I believe your problem is the first one, running from the Client instead of the server. Try using a [Command] or a NetworkMessage to get the Server to instantiate it for you.

Comment
Add comment · Show 4 · 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 ODINKONG · Oct 17, 2015 at 08:32 PM 0
Share

Awesome thank you. I was able to just change the function to a command and that fixed the problem

[Command] public void CmdmakeBoosterItem (Vector3 pos, float temp, int biome){ float Level = Vector3.Distance (pos, spawnPoint); GameObject Hr = Instantiate (healthRoot) as GameObject; Hr.transform.position = pos; Hr.GetComponent ().setNetworkOwner (player); Hr.GetComponent ().setLevel (Level); NetworkServer.SpawnWithClientAuthority (Hr,player); }

avatar image $$anonymous$$ ODINKONG · May 28, 2016 at 06:53 PM 0
Share

Please repeat what you wrote in <> on Hr.GetComponent ().setNetworkOwner (player);

avatar image ODINKONG · Oct 17, 2015 at 09:23 PM 0
Share

Ok so I am having a new issue now. I have switch most of the things that the object i'm spawning does over to the client by using if (hasAuthority) ins$$anonymous$$d of if(isServer)

However now I am getting this error from the server every time a client attempts to spawn something. found no receiver for inco$$anonymous$$g command. The server and the client should have the same NetworkBehaviour instances.

avatar image ODINKONG · Oct 17, 2015 at 09:28 PM 0
Share

ok i guess for some reason the health wasn't getting set on the client anymore. Probably has something to do with it being a syncvar. If you don't $$anonymous$$d could you quick go over how client authority sync vars work. Do I need to use a command to change them or can I just say if is server to modify them. I'm guessing they work the same way as the player sync vars do?

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

36 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

Related Questions

zombie network spawn! help" 0 Answers

Player Prefab on Lobby Managers? 5 Answers

Spawning a new player instance (UNET) 3 Answers

How to to spawn player, according to id? 0 Answers

Netcode [Command] Issues .. no errors, just not working. 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