Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Navajo · Nov 18, 2011 at 02:10 PM · networkingprefabnetworkprefabsnetwork.instantiate

How do i access a network instantiated object?

Hi i am making a network game and for now i want to identify the players by colour/texture. I don't want to change the prefab every time that someone spawns in the game so the only way i can see to do it is change it after i have ran Network.Instantiate().

Is it possible to get an object after this and then change the texture/material used or even just the colour?

If that is not possible is there anyway to instantiate to object to change it and put it on the "network" in another way?

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

Answer by syclamoth · Nov 18, 2011 at 02:31 PM

Network.Instantiate automatically sets up network views on all clients. This means that you can set up a script on any individual object, that goes something like this-

 public Color myColour = set it however you need to on the client;
 if(networkView.isMine)
 {
     networkView.RPC("SetColour", RPCMode.All, myColour.r, myColour.g, myColour.b);
 }
 // elsewhere

 [RPC]
 void SetColour(float r, float g, float b)
 {
     myColour = new Color(r, g, b);
 }
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 Navajo · Nov 18, 2011 at 10:52 PM 0
Share

Thanks for the answer i knew there had to be something. But this isn't working for me. Would this be because it is a prefab, basically the same as the Character controller in Standard Assets, and the $$anonymous$$aterial/colour is controlled by the the Controller->Graphics->$$anonymous$$esh Renderer->$$anonymous$$aterials?

avatar image syclamoth · Nov 18, 2011 at 11:58 PM 0
Share

Yes, that would be it. Give your script a reference to the mesh renderer (since it's not on the same object), and use that ins$$anonymous$$d. $$anonymous$$y code doesn't specify how you use the Color object once it's been passed around- that's up to you.

avatar image Navajo · Nov 19, 2011 at 01:39 PM 0
Share

mmm now I'm even more confused and still can't get it working, i'm not sure how i would reference the mesh renderer from the code, i have tried
character.GetComponentInChildren<$$anonymous$$eshRenderer>()

but it doesn't work, how do i reference it and then apply the new colour?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

problem using OnStartServer() for unity multiplayer networked game 0 Answers

Having problems with Network.Instantiate 1 Answer

[UNET] How to know the connectionID of a player ? 2 Answers

Check if a player has Network View 0 Answers

Network, Builds wont move 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