how do I say "if I press the key, ALL clients should see MY player's change?"
Photon RPC calls seem to affect my code in ways that appear to be close, but no cigars.
using UnityEngine;
using System.Collections;
public class sheildWeild : MonoBehaviour {
private bool weild;
private PhotonView myPhotonView;
public static string setRenderer = "SetRenderer";
// Use this for initialization
void Start () {
myPhotonView = this.GetComponent();
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){
//if ANYONE presses "`"
if(myPhotonView.isMine)//affect MY sheild
myPhotonView.renderer.enabled = weild;
//renderer.enabled=weild;
}
}
![alt text][1]
[1]: /storage/temp/18859-12-3pun.jpg
↧