So, I’m trying to send render states of specific objects equipped to my player. Here is my current code:
using UnityEngine;
using System.Collections;
public class sheildWeild : MonoBehaviour {
private bool weild;
public Renderer rens;
//GameObject SHEILD;
private PhotonView myPhotonView;
public static string setRenderer = "SetRenderer";
// Use this for initialization
void Start () {
myPhotonView = this.GetComponent<PhotonView>();
weild=true;
Debug.Log (weild);
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.BackQuote))
{
if(weild==false)
{
this.myPhotonView.RPC("SetRenderer", PhotonTargets.AllBuffered, true);
weild=true;
}
else
{
this.myPhotonView.RPC("SetRenderer", PhotonTargets.AllBuffered, false);
weild=false;
}
}
Debug.Log (weild);
}
[RPC]
void SetRenderer(bool weild){
this.renderer.enabled=weild;
}
}
This code allows all clients to see when a player’s shield is wielded or not. The problem is, all players on their client weild/unweild their shield. Only the client’s player should change render state.
the picture above displays the left client having a sheathed status, while the client to the right has wielded status. As the left client was the last to affect the status of the shield’s renderer.enabled property, he has not only affected his own shield on the other client’s view, but all shields in game.
How can I make the Boolean weild only affect the active client’s objects?

I was attempting to play with public Renderer rens; Now i'm thinking maybe I need to use public Renderer rens[]; and possibly pull the playerID into the array for location? I'm not sure how to pull the playerID or if this would even work
– KuPAfoo