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
0
Question by Deadly Firefly · Nov 25, 2013 at 04:05 PM · networkingcoloralphameshrenderer

Unable to change alpha property across network

Hi,

I've got a networked game set up. 2 teams playing versus each other, depending on which team you are your mesh changes color (either blue or red). This works fine. If I change the transparency before runtime it will work properly.

But if I try to change the alpha property of a mesh it only appears transparent on the player running the game instance, not across the network.

It's only updating the colors and not the alpha of the mesh during runtime.

Here's the code:

     //My color
     public float transparency = 1f;
     
     public MeshRenderer mRenderer;
     
     public Vector3 colorVectorBlue = new Vector3(0, 0, 100);
     public Vector3 colorVectorRed = new Vector3(100, 0, 0);
 

     void Awake () 
     {    
         mRenderer = transform.GetComponentInChildren<MeshRenderer>();
         
     }
 
     void CheckMaterial()
     {
         
         if(transform.tag == "BluePlayer")
         {
             networkView.RPC("UpdateMaterial", RPCMode.AllBuffered, colorVectorBlue);
         }
         
         if(transform.tag == "RedPlayer")
         {
             networkView.RPC("UpdateMaterial", RPCMode.AllBuffered, colorVectorRed);
         }
         
     }
 
     //Update my color across the network
     [RPC]
     void UpdateMaterial(Vector3 currentColor)
     {
         Color finalColor = new Color(currentColor.x, currentColor.y, currentColor.z, transparency);
         mRenderer.material.color = finalColor;
     }


What could be causing this?

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

Answer by Deadly Firefly · Nov 26, 2013 at 02:10 AM

I forgot to transmit the transparancy value, I was using the local one.

Here's the fix

         if(transform.tag == "BluePlayer")
         {
             networkView.RPC("UpdateMaterial", RPCMode.AllBuffered, colorVectorBlue, transparency);
         }
         
         if(transform.tag == "RedPlayer")
         {
             networkView.RPC("UpdateMaterial", RPCMode.AllBuffered, colorVectorRed, transparency);
         }

 void UpdateMaterial(Vector3 currentColor, float transp)
     {
        Color finalColor = new Color(currentColor.x, currentColor.y, currentColor.z, transp);
        mRenderer.material.color = finalColor;
     }
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
1

Answer by karljj1 · Nov 26, 2013 at 12:05 AM

Your RPC does not seem to transmit the alpha value, just the RGB, you then apply the xyz from your RPC and use the local transparency value. You need to transmit RGBA. Maybe use a Vector4?

Can you not transmit Colors instead of Vector3?

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 Deadly Firefly · Nov 26, 2013 at 12:36 AM 0
Share

It's impossible to send Vector4 or Color over RPC

avatar image Kiloblargh · Nov 26, 2013 at 01:22 AM 0
Share

RPcs can have as many (well, within reason) arguments to them as you want. You can just say

 void Update$$anonymous$$aterial (Vector3 currentColor, float transparency)

and then create a new Color with the Vector3 for RGB and the float for alpha and it will work.

avatar image Deadly Firefly · Nov 26, 2013 at 10:12 AM 0
Share

You're absolutely right and I completely forgot. I solved it like this. Thanks!

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

17 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

Related Questions

Problems With Alpha Channels When Loading DXT5 Texture2D From PNG 1 Answer

Float to Byte for Color32 3 Answers

Changing two different objects renderer colour 1 Answer

Alpha-based Color Mask 2 Answers

Alpha set by tag in GUI.Label / GUI text behaves strange way 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