How to use triggers with PUN?

I've been going at this for 3 days but I can't find any tutorial of how to get triggers working. I'm making a simple game, I've managed to get the players to join a room. I place a trigger and an AI has to go to its position. The AI interacts with the trigger alright but the player cannot interact with it. Both the trigger and AI are running on local machine.

Answers

  • Are you talking about handling an OnTrigger() event?

    If so, you can run a check to see if the owner of the "other" collider is your local player (photonView.isMine) and handle the event as you need.

    For example:

    private void OnTriggerEnter(Collider other)
    {
    PhotonView phView = other.gameObject.GetComponent<PhotonView>();

    if (!phView.IsMine)
    {
    // Not our local player - ignore
    return;
    }

    // Handle your event here
    }

    Hope this helps. :-)