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 /
  • Help Room /
This question was closed Dec 12, 2016 at 09:35 AM by Brylos for the following reason:

Other

avatar image
0
Question by Brylos · Dec 09, 2016 at 03:57 PM · networkingboolcommand

[Command] giving error: Trying to send command for object without authority

So I'm trying have my server change some bools specific to my player controller, and I'm pretty sure the code works, but I think something is wrong with my components. My player prefab network identity doesn't fix it when I uncheck local player authority. The bools effect the mesh renderer of my playercontroller and children of my player controller prefab(two cameras, and a mesh renderer)

Here's the full error:

Trying to send command for object without authority. UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String) PlayerController:CallCmdJoinRedTeam() UnityEngine.EventSystems.EventSystem:Update()

Here are the voids:

 [Command]
 public void CmdEnterSpectateMode()
 {
         PlayerCameraEnabled = false;
         PlayerIsVisible = false;
         GravityEnabled = false;
         PlayerBody = GameObject.Find("PlayerController(Clone)");
         PlayerBody.transform.position = new Vector3(500, 30, 675);
 }
 [Command]
 public void CmdJoinRedTeam()
 {
         PlayerCameraEnabled = true;
         PlayerIsVisible = true;
         GravityEnabled = true;
         PlayerBody = GameObject.Find("PlayerController(Clone)");
         PlayerBody.transform.position = new Vector3(617, 10, 500);
         PlayerBody.transform.localRotation = Quaternion.Euler(0, -90, 0);
 }
 [Command]
 public void CmdJoinBlueTeam()
 {
         PlayerCameraEnabled = true;
         PlayerIsVisible = true;
         GravityEnabled = true;
         PlayerBody = GameObject.Find("PlayerController(Clone)");
         PlayerBody.transform.position = new Vector3(383, 10, 500);
         PlayerBody.transform.localRotation = Quaternion.Euler(0, 90, 0);
 }

Does anyone know how I can fix this? Thanks in advance.

Comment
Add comment · Show 5
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 Ralp7 · Dec 09, 2016 at 04:15 PM 0
Share

Every player object has own network id. I think, you can't reach them with GameObject.Find function. If you are new to networking, i suggest this video tutorials. It is pretty good. I watched it and after that i understand most of basic networking stuff.

$$anonymous$$aking a $$anonymous$$ultiplayer FPS in Unity

avatar image Brylos Ralp7 · Dec 09, 2016 at 04:25 PM 0
Share

That's a great tutorial series that I've been watching but that's not the issue. It worked before I added the [command] to the void. And just to be sure I removed that part of the code and still get the same error.

avatar image pKallv · Dec 10, 2016 at 07:28 PM 0
Share

And you are sending this from your "local" player?

avatar image Brylos pKallv · Dec 11, 2016 at 11:50 AM 0
Share

Yes. I'm trying to have it so when the local player clicks a UI button they move position and their camera properties change depending on which button they click

avatar image Brylos · Dec 11, 2016 at 01:15 PM 0
Share

This kind of sucks, because even after I managed to get rid of the error, the bools aren't changing :( The player moves into the correct position but the bools stay the same

1 Reply

  • Sort: 
avatar image
0

Answer by AurimasBlazulionis · Dec 10, 2016 at 07:47 PM

It does not matter if LocalPlayerAuthority is checked or not. You can only call commands on player objects. So, if you want to call a command, the component has to be attached to the root of the player.

To check if you are OK on the client side, do Debug.Log(isLocalPlayer). If it returns false, then it is not your player. If you are writing a customized NetworkManager, you could be not giving the authority to the player.

Comment
Add comment · Show 1 · 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 Brylos · Dec 11, 2016 at 12:26 AM 0
Share

Can you really not access components on children of the playerprefab? That seems odd, and It messes up the camera on my playercontroller for looking.

Follow this Question

Answers Answers and Comments

105 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

Related Questions

How do I use an InputField to change a player object's variable? 1 Answer

How would I store local data on the server, without overwriting that server's own data? Essentially making a copy. 0 Answers

How to command dedicated server 1 Answer

Sending Command from client to server Using an UI button 0 Answers

[Command] Not being called at all 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