Other
Networking With Colors Unity 5
I haven't found an answer yet for this that works. I am trying to make an object opaque with a left click and have it appear the same on a client window. Does anyone know how to send color data over a network with Unity 5?
Edit: Also the changing game object is a child.
Answer by Soos621 · Jul 19, 2016 at 05:28 PM
If the color variable itself can't be sent over the network then you can always set the rbg values of the colors to a vector3 then send that if that doesn't work then you can take each value from the Color and set it to a float
Both of these don't work. I should also mention that the game object that changes is a child, and I use Transform Child in the inspector of the root object.
Are you setting the material directly? You will need to take a color from the object send the color over the network then reapply it to the client objects material
The object being a child shouldn't have any interference with this process
I'm not sure if I am doing the same thing that you are suggesting so please tell me. Specifically what I did was create a material for transparent and another one for opaque, then set each one on a click down/up key, but that didn't work either.
How are you changing the material on the object? I assume that your doing something like
Public material coloredmaterial; Public material Transparent material;
if(input.getmousebutton(0)){ This.getcomponent().material = coloredmaterial; }
You can also change the color of the material by using a material.albedeo I believe sry if there are some mistakes I'm not at my pc
Yes pretty much the same thing but G e t C o m p o n e n t < S p r i t e R e n d e r e r > ( ) . I will try this when I get back as well though
Answer by rmassanet · Jul 20, 2016 at 07:26 AM
Instead of sending the colour over the network, why not calling a method in all clients that sets the desired colour?
I'm not sure how to call methods of other objects through a network. Also i have been playing around with setActive to see if I can find a different solution. If you could tell me how I will try it
You can use RPC for that. Check the Unity Networking tutorial. This section talks about RPCs, but I would recommend you go through all the networking section:
https://docs.unity3d.com/$$anonymous$$anual/UNetActions.html
I had thought about reading the entire networking section of the manual from the beginning but there is way too much content for me to go through (as for trying a fun quick networking project for the summer). Also everything I have attempted with RPC has not worked. I have been trying to get this last part of my program to work for over 2 week now, so I will probably end up reading through the networking manual since I have tried everything else, and quit mid way through. Anyway, thanks for trying to help out.