RPC with PhotonTargets.All not transforming position of all

Options
Hi, I was hoping I could get some help. Im doing a multiplayer game which in a part consist of a course in which players go from one side of the course to the other.

The problem im having is that I want to TRANSFORM THE POSITION OF ALL PLAYERS TO THE END OF THE COURSE when ONE (the first player that arrives) of the players get to the end of the course (it doesnt matter where they were before, they will all transform position to the end of the course when the first one arrives) . I cant seem to achieve this, this is what I am doing so far (which isnt working):

I made a trigger gameObject at the end of the course, so that when any of the players enter the trigger the "void OnTriggerEnter" runs and calls for an RPC call:

void OnTriggerEnter (Collider col){
if(col.gameObject.tag=="wintrigger") {

GetComponent<PhotonView> ().RPC ("win", PhotonTargets.All, null);
}
}

Then the RPC is supposed to "transform.position" all players to the new Vector3, since the parameter is PhotonTargets.All. But this is not happening, only the player that touches the trigger is the one that moves to the Vector3 the other players stay on the same position they were. The RPC has the following code:

[RPC]
public void win (){
position= new Vector3 (5.447705f, 0.3251734f, 4.311719f);
transform.position = position;
}

Why is this not working? What am I doing worng? Thanks!

Best Regards.

Comments

  • vadim
    Options
    HI,

    In win() method you should set position not for local instance of winning player but for local player.
  • Cyoz
    Options
    Would you mind providing me an example of how to do this? Thanks a lot.