detect the real player of the clone

hi every body i am making a multiplier car game and my question is . is their any way to detect the real player that i collide with clone of it

like if i am a car hit other car in the game make the player of the other car know that is me hit him

thanks :idea:

Comments

  • Yes, it's relatively simple.

    Each player has a PhotonView, and you can check the PhotonView.isMine attribute to find out if yours is local. If you want to tell the other player, you'd do an RPC to their specific PhotonPlayer object. So, for example:

    private PhotonView pView;
    void Awake()
    {
    pView = GetComponent<PhotonView>();
    }

    void OnCollisionEnter (Collision c)
    {
    if (c.gameObject.Tag == "Player")
    pView.RPC("Hit", c.gameObject.GetComponent<PhotonView>().owner, /* any variables sent along here in an array */);
    }

    [RPC]
    void Hit(/* variables */)
    {
    Debug.Log("Oh no, we've been struck!");
    }

    I'd read up on the Photon Cloud docs, they have a good section on RPC calls and it'll help you understand it better. Any other specific questions, lemme know!
  • Thanks for answerring that. The key is indeed to check the PhotonPlayer via a PhotonView.