- Home /
How to change GameObject Material over Network!
Hello,
Im trying to set up this Invisibility power up, which is activated OnTriggerEnter(), and I know that the material of the player will change localy, so how do I use RPC's to let everyone else see that my material has been changed!
This is the script that I've just coded, do you think it works?
private var Invis : boolean;
var InvisRedMat : Material;
var InvisBlueMat : Material;
function OnTriggerEnter(what : Collider)
{
if(what.gameObject.tag == "Invis")
{
Invis = true;
}
}
function Update()
{
if(Invis == true)
{
if(gameObject.tag == "RedTeamPlayer")
{
networkView.RPC("InvisRed", RPCMode.AllBuffered);
}
if(gameObject.tag == "BlueTeamPlayer")
{
networkView.RPC("InvisBlue", RPCMode.AllBuffered);
}
WaitAndRemoveInvis();
}
}
function WaitAndRemoveInvis()
{
yield WaitForSeconds(60);
Invis = false;
}
@RPC
function InvisRed () {
renderer.material = InvisRedMat;
}
@RPC
function InvisBlue () {
renderer.material = InvisBlueMat;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613103516im_/https://answers.unity.com/themes/thub/images/avi.jpg)