- Home /
Photon - RPC Does Trigger but Does not Show Over Network :(
Hello! So I have a script that launched an RPC method called onFirePress. I know that calling the method works because I have a Debug.log statement that tells me that. However, underneath the Debug.log statement I am trying to activate a bullet object and play a shooting animation for that player. The bullet is activated and the shooting is played but it does so only on my own client. No other network players can see this happen. Can someone please help me out (I've been working on this for days)? Am I just using RPCs wrong? BTW: I do have a photon view on each GO that I call an RPC method from.
Setting the Bullets and Buttons (Awake Method):
void Awake()
{
Joystick = GameObject.FindGameObjectWithTag ("Joystick");
MovementJoystick = ((CNJoystick)Joystick.GetComponent (typeof(CNJoystick)));
fireButton = GameObject.Find ("Fire Button").GetComponent<Button> ();
jumpButton = GameObject.Find ("Jump Button").GetComponent<Button> ();
drinkButton = GameObject.Find ("Drink Button").GetComponent<Button> ();
//Get both Bullets
leftBullet = this.gameObject.transform.FindChild("Gus_Skeleton").gameObject.transform.FindChild("Gus_Torso").gameObject.transform.FindChild("BulletLeft").gameObject;
rightBullet = this.gameObject.transform.FindChild("Gus_Skeleton").gameObject.transform.FindChild("Gus_Torso").gameObject.transform.FindChild("BulletRight").gameObject;
}
Setting PhotonView and Getting Button Calls (Start Method):
//Get Photon View to use for Buttons
pv = this.gameObject.GetComponent<PhotonView> ();
if (pv == null) {
Debug.LogError ("You Have no Photon View Attached in the Player GO to call FlashMuzzle!");
}
//Button Functions
fireButton.onClick.AddListener(() => { pv.RPC ("onFirePress", PhotonTargets.All); });
drinkButton.onClick.AddListener(() => { pv.RPC ("onDrinkPress", PhotonTargets.All); });
jumpButton.onClick.AddListener(() => { onJumpPress(); });
//Get Arm Animatior
armAnim = this.gameObject.transform.FindChild("Arms").gameObject.GetComponent<Animator>();
//Get this instance of the PlayerController Script
thisPC = this.gameObject.GetComponent<PlayerController> ();
The RPC onFirePress Method:
[PunRPC]
public void onFirePress()
{
if (Fire.bulletShot == false && Fire.reloading == false) {
if (thisPC.facingLeft == true) {
// Shoot Gun Left
Debug.Log(this.gameObject.name + " is FACING LEFT");
armAnim.SetInteger ("EquipAnim", -1);
armAnim.Play ("ShootIdleLeft", -1, 0f);
//Activate Equip1 Gun Bullet
rightBullet.SetActive(false);
leftBullet.SetActive (true);
}
if (thisPC.facingLeft == false) {
// Shoot Gun Right
Debug.Log(this.gameObject.name + " is FACING RIGHT");
armAnim.SetInteger ("EquipAnim", 1);
armAnim.Play ("ShootIdleRight", -1, 0f);
//Activate Equip2 Gun Bullet
rightBullet.SetActive (true);
leftBullet.SetActive (false);
}
Fire.bulletShot = true;
Fire.flashMuzzle = true;
}
}
Q: The RPC only shows on my client. How can I fix it to make it show on ALL clients?
Thanks for Reading!