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?

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?

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;
    }