Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[Photon] HELP! PhotonTargets.AllBuffered Not Working!

Discussion in 'Connected Games' started by Nsingh13, Aug 2, 2016.

  1. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    18
    I have an RPC method that sets a pickup object active from an object pool.

    Code (CSharp):
    1. [PunRPC]
    2. public IEnumerator InstantiatePickups()
    3. {
    4. GameObject newPickup =  Pool.GetPooledObject();
    5. newPickup.SetActive (true);
    6.  
    7. yield return new WaitForSeconds (0.1f);
    8.  
    9. Debug.Log("Done");
    10. }
    I then call it when someone kills a player with this:

    Code (CSharp):
    1. scriptthathasthemethod.pv.RPC ("InstantiatePickups", PhotonTargets.AllBuffered);
    This works all well and nice, but when a new player joins the room, the pickup is not set active for him/her. I've been working on this all day and can't figure out what's wrong. Any help is highly appreciated!

    P.s. I'm using Unity 5.3
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,229
    Are you saying InstantiatePickups() doesn't get called?
    If so, make sure the scriptthathasthemethod.pv is existing for the clients that join.
    Also check if you're loading scenes when joining. If the scene finishes loading after you joined, the activated objects get destroyed again and it looks like nothing happened.
     
  3. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    Don't buffer it. The pool should have event system that will send a event to every new player that joins.
    For example You send raiseEvent with true or false and the pickupID so the player will know which pickUP you mean.
     
  4. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    18
    Ah! That's my problem! scriptthathasthemethod does not exist when a new player joins because player with that script is long dead. So.. I'd have to call the rpc method from a script attached to a gameobject that never goes away. Any easy ways of doing this?

    Thanks for the response!
     
  5. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    18
    @tobiass Just wanted to let you know that I fixed it by adding another Photonview on a non-player object and then adding scriptthathasthemethod to that particular object. Thank you!
     
    tobiass likes this.