How to use triggers with PUN?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How to use triggers with PUN?
Laplace
2020-09-03 14:37:52
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.
Comments
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
if (!phView.IsMine)
{
// Not our local player - ignore
return;
}
// Handle your event here
}
Hope this helps. :-)
Back to top