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
1
Question by sonic220 · Jan 31, 2016 at 05:44 PM · networkingobjectclient-serverclients

sending commands from multiple clients

I'm experimenting with HLAPI and I'm facing a simple problem that doesn't seem to be handled by any of the functionality provided by the netwoking system. Let's say I have a simple cube in the scene that starts moving when any client press a button. It seems that I can send a command to the server from a client if the client has the authority over that object, however this page sates: http://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.AssignClientAuthority.html

Only one client can own an object at any time

Let's say the players have simply to cooperate based on client inputs of a central copy of the object on the server (the case of the cube), how can one make remote objects receive commands from multiple clients?

code example:

     [Command]
     void CmdToggleMoving(){
         moving = !moving;
         logger.ShowMsg("Moving: " + moving);
     }
 
     void checkObjectClick(){
         if(Input.GetMouseButtonDown(0)){
             RaycastHit hit;
             Ray ray;
             if(settings.usingVufuia)
                 ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             else
                 ray = settings.selectedDebugCamera.ScreenPointToRay(Input.mousePosition);
             if(Physics.Raycast(ray, out hit)){
 //                Debug.Log("hit something " + hit.transform.name);
                 if(hit.transform.name == this.transform.name){
                     CmdToggleMoving();
                     logger.ShowMsg("Moving: " + moving);
                 }
             }
 
         }
     



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 Teravisor · Jan 31, 2016 at 10:22 PM

Make several separate invisible objects for each player which they own; make a command on them that moves a cube; now each client sends command to his(her) own object causing cube(same for both) to move.

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 sonic220 · Feb 01, 2016 at 08:46 PM 0
Share

I get the point of this, but to me it seems highly impratical because I should derive the object behaviour and assign it to something other (that a player owns). $$anonymous$$eaning this separate object should have the reference of the cube, but lets say we have 10 or 20 cubes and each one has a different behaviour, what should I do then? reference each one of them?

why I can't just assign ownership of a object to multiple players?

avatar image
0

Answer by OndrejP · Nov 20, 2017 at 07:20 AM

Add NetworkBehaviour script to player object. This script will contain the command method. On server it will find the cube (which can be also passed as command argument) and control it. This way multiple players can move it at the same time.

This will work, because each client is invoking command on the player-owned object (the player).

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

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

50 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

Related Questions

UNET Different size of spawned object on host and client 1 Answer

Unet Networking: having two clients in the editor instead of building for standalone? 0 Answers

UNet Portal 2 Like Object Interaction Client to Server 1 Answer

[UNET] Only spawn certain server objects on local client? 0 Answers

How to watch in client applications what it is happening in the server one? 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