Master Local

Master local is a fake Broadcast Type created such that the trigger can only be initiated by master but is also executed local only for master. The reason this is a fake broadcast is because Master local is not included in the SDK.

Please vote to have this added as an official feature to the SDK

Prefab

Prefab by CyanLaser can be downloaded here.

How it works

Overview: There are three steps involved. First, the local player turns off the gating trigger. Then the local player calls a trigger to turn it back on only if the local player is master. Third, the final desired action is triggered, but only if the gate was passed by the master. If the local player was not master, the gate will not be passed and the action will fail.

Here is how this works in the setup described below:

  1. The first step is to disable Gate's trigger component. If a VRC_Trigger is disabled, then all custom triggers on it will not fire even if called. This is a way of gating actions or turning off logic.
  2. The second step is to call "MasterOnlyEnable". This trigger has a broadcast type of MasterUnbuffered. This means that only Master can initiate it and it will be broadcast to everyone. Since master is the only one who can initiate it, it will fail for everyone who is not master, skipping over it. This is our test to see if the local player is master. Only the master can initiate enabling Gate's VRC_Trigger.
  3. The last step is to call "MasterOnlyAction". If the previous step failed, then the trigger will be disabled thanks to step 1 and this action will also fail. If the previous step passed, then this trigger will be enabled and the trigger will fire.

All of this is dependent on custom triggers being executed in order and on the same frame. Even though "MasterOnlyEnable" is a global broadcast, causing everyone to enable Gate's trigger, the first step ensures that it will be turned off before trying to call it.

Setup

The basic master local trigger can be set up with two GameObjects, each with a VRC_Trigger script, and 3 total Custom Triggers. This only allows for master only, but you can edit this setup to perform "master local" and "not master" triggers as well as "owner local" with slight modifications.

Create two GameObjects, one for the main events and another for gating only for master. I will refer to these objects and their triggers as "Events" and "Gate". Be sure to check the advanced checkbox for both of these triggers.

The first step is to add a VRC_Trigger script to both Events and Gate.
On Gate, add a single Custom trigger. Name this "MasterOnlyAction". Set the broadcast type to local. Add anything you want to have happen only on the master client here. Disable the VRC_Trigger component.

Note: I recommend not adding broadcasts to this object. It has been observed that clients with triggers disabled will not fire them, even if remote clients tell them to. You should use Events to add any extra broadcasting actions and keep Gate entirely local.

On Events, add two Custom triggers. Name the first "MasterLocalTest" and the second "MasterOnlyEnable". "MasterLocalTest" is the custom trigger that you will call through ActivateCustomTrigger to perform the master local actions.

Inside "MasterLocalTest", add a SetComponentActive. Drag Gate into the receivers, select VRC_Trigger, and set it to false.
Add two ActivateCustomTrigger actions. In the first, drag Events in and select "MasterOnlyEnable". In the second, drag Gate in and select "MasterOnlyAction". Set the broadcast type of "MasterLocalTest" to local.

Inside "MasterOnlyEnable" add a single SetComponentActive. Drag Gate into the receivers, select VRC_Trigger, and set it to true. Set the broadcast type of "MasterOnlyEnable" to MasterUnbuffered.

Not Master Broadcast

Using the setup above, swapping the SetComponentActive's to the opposite values in both "MasterLocalTest" and "MasterOnlyEnable" will ensure that only Master will turn off Gate, meaning everyone but master can initiate it. The prefab above includes callbacks for both master and non masters.

Owner Local

This setup can be modified to also be Owner local. Ownership is dependent on VRC_ObjectSync. The main difference is that Events should be on the GameObject with the VRC_ObjectSync component. The second is that we need an additional custom trigger to properly handle the OwnerUnbuffered broadcast type. Owner broadcast types will fire based on if you are the owner the receiver of the trigger and not based on the owner of the object that has the trigger.

  1. To update the Master local to Owner Local, first replace all "Master" text with "Owner".
  2. Next, add a new custom trigger and name it "OwnerOnlyEnableLocal". Set the broadcast type to Local. Inside "OwnerOnlyEnableLocal" add one SetComponentActive. Drag Gate into the receivers, select VRC_Trigger, and set it to true.
  3. Inside "OwnerOnlyEnable", remove the SetComponentActive action. Instead, add an ActivateCustomTrigger action. Drag Events in and select "OwnerOnlyEnableLocal". Be sure to change the broadcast type of "OwnerOnlyEnable" from MasterUnbuffered to OwnerUnbuffered.