- Home /
Question by
KuPAfoo · Dec 04, 2013 at 05:33 AM ·
photonkeypressrenderer.enabledismine
Keypress.ismine?
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<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){
//if ANYONE presses "`"
if(myPhotonView.isMine)//affect MY sheild
myPhotonView.renderer.enabled = weild;
//renderer.enabled=weild;
}
}
Comment
Your answer
Follow this Question
Related Questions
photonView.isMine Problem [Help!] 1 Answer
What key was pressed? 4 Answers
Teleportation 1 Answer
Should character direction come from key press, or third person controller vector3? 0 Answers