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 DaanSander · Aug 12, 2016 at 01:29 PM · c#networkingcommand

Trying to send command for object without authority - on a networkidenity with local authority

Im trying to send a command so that a the health of an enemy will be subtracted by sending a command to the server but I keep getting the warning: Trying to send command for object without authority. While the NetworkIdentity on the gameobject is set to local authority. Can anybody help me with this

This is how the command is called:

  public void damageEnemy(GameObject enemy, float damage) {
             if (!isLocalPlayer) return;
             EnemyManager enemyManager =    enemy.GetComponent<EnemyManager>();
             if (enemyManager == null) return;
             enemyManager.CmdDamage(damage);
         }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Remingsworth · Oct 01, 2017 at 08:04 AM

It sounds like there are 2 issues here. 1) You said you are calling the networking method from a child object. You need to have all your networking stuff on the parent object (all networking scripts and only 1 network identity which should have Local Player Authority). Just make references from the scripts on the player parent to tell the child objects what to do. 2) You shouldn't have commands on a non-player object. Commands are sent from the client to the server and not from non-player objects to the server. You need to use something like [SyncVar] to sync the health of the enemy over the network.

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 DiegoSLTS · Aug 12, 2016 at 01:40 PM

What gameObject's NetworkIdentity has local authority? It sounds like you set local authority for the object with that script, but you need local authority on the enemyManager object to send commands from that object.

Comment
Add comment · Show 3 · 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 DaanSander · Aug 12, 2016 at 02:13 PM 0
Share

Yes the object of that script has the authority but I call the method from a child object

avatar image DiegoSLTS DaanSander · Aug 12, 2016 at 02:52 PM 0
Share

I'm not sure what you meant, the enemy$$anonymous$$anager object hast local player authority set?

Note that for non-player objects setting "local player authority" is not enough to be able to execute commands, you have the set who's the player (client) that has authority, since the object exists for all the clients but only one can have authority over it.

Check this link, specially the "Client Authority for Non-Player Objects" section: https://docs.unity3d.com/$$anonymous$$anual/UNetConcepts.html

avatar image Remingsworth DiegoSLTS · Oct 01, 2017 at 08:04 AM 0
Share

You don't want to assign Local Player Authority on an enemy just to deal damage... everyone online would be fighting, so to speak, over who has authority to deal damage.

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

6 People are following this question.

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

Related Questions

Can I use Rpc Calls and Commands on the same object? 0 Answers

UNET Server not setting [SyncVar] 0 Answers

Trying to send command for object without authority. - change color of object from client 0 Answers

SyncListString not changing in a Command 0 Answers

SyncListString not changing properly 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