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 roamcel · Aug 05, 2011 at 08:33 AM · multiplayercomponentrpcadding

Retrieve gameobjects from a network.player, adding multiplayer components

Hi, I have a very basic but correctly working multiplayer non authoritative setting based on the official material. I have the need to perform some specific client side actions on a gameobject, and I'm considering the RPC approach (for ease of implementation).

I have the following need:

 1 - A gameobject (called A) performs an action that adds a component to it
 2 - the gameobject A sends an RPC to the others telling that he has added the
     component
 3 - the other gameobjects update their local copy of A, adding the component to A
     (for example determining its class from a variable name)
 4 - ?
 5 - profit!

besides point 4, about which I'll worry about in the future, I can't for the life of me figure how to correctly implement point 3, and tell the 'others' that SPECIFICALLY gameobject A has added the component. I mean, surely you can identify a 'player' thanks to the RPC parameters, but what's the way to associate a player with its multiplayer gameobjects? I was hoping for something like

 Gameobject[] networkplayergameobjects = Gameobject.Find(Network.player);

so that i could iterate and find by name, for example, but sadly there's no such thing.

Any help is appreciated.

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
1
Best Answer

Answer by PatrikNyblad_SI · Oct 03, 2011 at 09:32 AM

I might not be the best to answer this but my approach is to keep an Array of objects in the same order on all connected devices and then just check the index of the object i want to mess with and send that index over the network.

The player might contain a few objects like

PlayerPrefab

  • Character

  • Gun

  • Shield

  • and so on...

In the PlayerPrefab I just keep the reference array and networkview together with control scripts and other things vital to my character. I just perform an RPC call saying that object at index N should perform something.

Hope it helps :)

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 roamcel · Oct 03, 2011 at 11:49 AM 0
Share

Your suggestion requires some serious refactoring, but for the lack of other proposals seems certainly like the one to go along with.

Thanks.

avatar image B-rad · Nov 02, 2012 at 07:35 PM 0
Share

I'm getting started with Unity Networking as well. Could you offer an explanation of how you'd put the array on the network?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity NetworkViewID Collision problem 0 Answers

Using .SetActive() over Unity Network for multiplayer. (Enable weapons on clients) 1 Answer

Networking pattern for team-based play 1 Answer

Multiplayer - Handling players leaving 1 Answer

RPC Calls in 5.1 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