Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
2
Question by Dust-Cloud · Jul 28, 2015 at 03:57 PM · networkingunity multiplayer

How to give a client authority over an object in UNET?

How would i go about doing this? NetworkIdentity.hasAuthority and NetworkIdentity.playerControllerId are both read only and NetworkIdentity.localPlayerAuthority's doc says that "LocalPlayerAuthority means that the client of the "owning" player has authority over their own player object." but i don't know how to have a player own an object

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

3 Replies

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

Answer by nisovin · Jul 28, 2015 at 04:50 PM

These pages of the documentation talks extensively about player objects in UNet, including how to spawn them:

http://docs.unity3d.com/Manual/UNetManager.html

http://docs.unity3d.com/Manual/UNetPlayers.html

Keep in mind in the current version of Unity you can only have one object with authority per player in the game, and that's the player object.

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 Dust-Cloud · Jul 28, 2015 at 10:48 PM 0
Share

the links were very helpfull, i kept looking for something to define the owner like in the previous networking system without realizing there were special objects for that now. but any way to prevent confusion here is a quote from the docs about having multiple player objects per client.

"In most cases there is a single player for each client. But, in some situations - such as when there are multiple controllers connected to a console system, they could be multiple player objects for a single connection. When there are multiple players for a connection, the playerControllerId property is used to tell them apart. This is an identifier that is scoped to the connection - so that it literally maps to the id of the controller associated with the player on that client."

avatar image Jason-H · Oct 01, 2015 at 01:01 PM 1
Share

As stated in my answer, as of Unity 5.2 you are now able to give clients authority over non-player objects. See: http://docs.unity3d.com/$$anonymous$$anual/UNetConcepts.html

avatar image
3

Answer by Jason-H · Oct 01, 2015 at 01:00 PM

As of Unity 5.2 we are able to give clients authority over non-player objects.

See the section titled "Client Authority for Non-Player Objects" here: http://docs.unity3d.com/Manual/UNetConcepts.html

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 grandmapuckett · Jul 28, 2015 at 06:23 PM

Are you making a game that involves the concept of controlling game pieces? Like units in an RTS, or players in a party on a RPG, or what have you?

If so, i had the same problem, and not knowing any better, i made my own simple system: in the game, every object that can be controlled by a player has a string variable "Owner" that gets filled when that object is created with the name (or identifier, or what have you) of whatever player or game entity is requesting its creation.

You can make that string a Syncvar, so that the owner string of that piece is the same on all clients,and then you can play around with it, so for example, on each client you could check who is your local player, then check a game piece's owner: if the owner string matches the local player, that game piece is a friend on that client, otherwise it's an enemy. You could use the same check to allow that piece's function to be called (or not) by a given player.

It's crude, and I bet there are more elegant solutions around, but this works for me. Hope that helps or at least gives you some ideas.

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 Dust-Cloud · Jul 28, 2015 at 10:50 PM 0
Share

UNET makes it so that even if the client knows that it is meant to control an object it can't send RPCs to the server unless the client owns that object so that solution wouldn't work unfortunately :(

avatar image grandmapuckett · Jul 29, 2015 at 10:24 AM 0
Share

Due to Commands and ClientRPCs not being usable outside of player objects? Bummer. I don't understand why Unet kinda implies that the only objects that can talk to their server counterparts and viceversa are just player objects.

avatar image Slight0 · Aug 16, 2015 at 03:48 PM 1
Share

In an RTS, the client doesn't have authority over its units. The player controller object itself send commands to the server telling the server what it wants to do with those units (move, attack, etc). The server then realises these actions and tells the client what happened.

It is not the client's responsibility to simulate the position of the units or anything else; this is how all professional RTS games are designed. Anything less would be potentially exploitable or otherwise unstable.

avatar image SwordfishJellymaster Slight0 · Jun 25, 2016 at 07:57 PM 0
Share

This is actually a quesion I have myself. How would one implement an RTS in Unet? I don't want to give my client authority over the actual units. I just want the client to send his input to the server and let the server handle all objects.

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

UNET NetworkServer.Spawn intermittently not called on clients 1 Answer

Unity networking tutorial? 6 Answers

Local IP adress in UNet 4 Answers

[UNet] "No such host is known" error on iOS 1 Answer

UNet. Messaging not work. Please help. 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