Skip to content

CyanTrigger Interface

CyanLaser edited this page Aug 12, 2021 · 2 revisions

CyanTrigger Component

CyanTrigger

CyanTriggers consist of two components: The CyanTrigger Component and an UdonBehaviour Component. Since this is SDK3, the UdonBehaviour is necessary for everything to work in game. The CyanTrigger component is just a fancy UI for creating Udon programs. When you add a CyanTrigger to a GameObject, an UdonBehaviour is also added and linked to that CyanTrigger. You will do all work in the CyanTrigger and not in the UdonBehaviour.

Other Settings

OtherSettings

The Other Settings section is a contextual section. This will only appear when needed based on the components on the object or the events used in the CyanTrigger. Currently there are only two options: Update Order and Interact options.

  • Update Order will only appear when the CyanTrigger has an updated event. There are 4 different update event types: Update, LateUpdate, PostLateUpdate, and FixedUpdate. The Update Order option allows you to change when this CyanTrigger performs its update relative to other CyanTriggers. Lower values will be executed before higher values.
  • The interact options will only display when the CyanTrigger has the Interact event. These options allow you to change what text is displayed when interacting with an object and how close the user needs to be for the interact option to activate.

Errors and Warnings

Error

When working with CyanTriggers, some actions may be improperly setup which will cause compile errors. These errors will be displayed in the console and on the CyanTrigger itself. If you see red text at the top of the CyanTrigger, the CyanTrigger could not compile and needs to be fixed before it can be compiled again.

Warning

CyanTriggers can also have warnings, which will appear in orange at the top of the CyanTrigger. These do not block compiling of the CyanTrigger and are for finding potential issues.

Comments

CyanTriggerComment

You can add comments in different areas of the CyanTrigger. The first location is at the top of the CyanTrigger itself. Currently you can only add comments by right clicking near the top of the CyanTrigger and selecting the "Edit CyanTrigger Comment" option. Type out the comment and press Shift + Enter or click the checkmark to finish editing the comment. Comments can also be added to events and actions.

Variables

Variables

The next section is the variables section. This is something not included in SDK2 VRC_Triggers. This section is entirely optional, but is helpful in creating more complex systems. A variable is a way to save data on the object that events and actions can access. Variables can also be synced so that every player in the instance has the same data, including late joiners. If you are new to using variables, see the Variables page for more details.

CyanTriggers allows you to have multiple global variables that can be accessed in action editors. Each variable in the variable list has four sections:

  • Name - This is the name of the variable and how it will be referenced in the action editor
  • Type - This is the type of the variable and what data can be stored in it.
  • Value - What data is stored in this variable by default.
  • Sync - Should this variable be synced to all players. The options for this are: Not Synced, Synced, Synced Linear, and Synced Smooth.

There are four buttons at the bottom of the variables list:

  • Star - Add a new variable, picking from the list of favorite variable options. This list is custom and can be set by the user in the CyanTrigger settings.
  • Plus - Add a new variable, picking from the list of all possible variable options.
  • Two Page - Duplicate the selected variables.
  • Minus - Delete the selected variables.

Sync Method

At the bottom of the Variable list is the Sync Method for the CyanTrigger and UdonBehaviour. This section only matters if you are syncing variables or using VRC_ObjectSync on this GameObject. VRChat has two methods for syncing variables: Continuous sync and Manual Sync.

  • Continuous Sync is used for variables with data that changes often. An example would be trying to sync an object's position. VRChat will automatically take this data and send it to all clients periodically. Continuous sync can be slow and takes network bandwidth. Even if the value never changes, VRChat will still send the data over the network.
  • Manual Sync is used for data that doesn't change often. When you change a synced variable, you need to manually request VRChat to sync the data by calling UdonBehaviour.RequestSerialization. Manual sync is much faster than continuous and is the recommended method for syncing variables. With CyanTriggers, there is an extra option called "Manual With Auto Request" that will automatically handle calling Request Serialization for you whenever you change the value of a synced variable.

Check the Networking page to learn more about Synced variables and VRChat networking.

VRC_ObjectSync

Note that if you are using VRC_ObjectSync on the GameObject, all CyanTriggers and UdonBehaviours MUST be set to continuous sync. The CyanTrigger will display an error if you have the sync mode set to Manual Sync while the object has the VRC_ObjectSync component. The solution is to either move the ObjectSync to another object, or set the CyanTrigger to Continuous Sync. If you need manual sync, then you will need to move those synced items to another object without the VRC_ObjectSync component.

Events

EventHeader

In CyanTriggers, Events are the start of the logic. Events define when actions will happen, what actions will happen, and who will perform the actions.

Event Header

EventHeader

The Event header has many different settings and buttons. The first two are the main ones in defining the event.

Event Type and Variant

The Base Event Type is the event that VRChat and Unity will call when something happens. There are many different event types. It is best to read the Unity MonoBehaviour docs and VRChat docs to know when each will fire. The Event Variant is an option only available when a Custom Action has been defined for a specific event. By default, the variant will be "VRC_Direct". This means no additional logic will happen to check if the event should fire. Most Event variant Custom Actions are used to provide gating logic. As an example, in the screenshot above, the event type is OnPlayerTriggerEnter. This event will fire when any player enters the trigger on the object. The event variant is LocalPlayer. This variant will ignore remote players, and only allow the event to fire if the player was the local player. See the Custom Action for more details on defining event variants.

Event Gate - Who can activate

EventGate

CyanTriggers have multiple options for gating who can activate an event. The default option is that anyone can activate the event, but there are 6 options. If someone tries to activate an event, but do not pass the event gate, then the event will execute and nothing will happen.

  • Anyone - Anyone in the instance can activate this event.
  • Owner - Only the owner of this object can activate this event. Owner refers to object ownership. Check the Networking page to learn more.
  • Master - Only the master of the instance can activate this event. The master is always the player who has been in the instance the longest.
  • Allow List - Any user whose name is included in the User List can activate this event. Selecting this option adds a User List where you can input names of different users.
  • Deny List - Any user whose name is not included in the User List can activate this event. Selecting this option adds a User List where you can input names of different users.
  • Instance Owner - Only the instance owner can activate this event. The instance owner is the user who created the instance by dropping the portal. Note that for public instances, there is no instance owner.

AllowList

Example of User Allow List which allows "CyanLaser", "LocalPlayer1", and any user who has the same display name as the variable SomeUserName.

Event Broadcast - Who will activate

Broadcasts

There are three different options for who can execute the event.

  • Local means only the local user who activated the event will execute the event.
  • Send to Owner will only execute on the player who owns this object. The owner does not need to be the one who activates this event, but they will be the one who executes it.
  • Send to All means that everyone in the instance will execute the event. At this time, the buffering system from SDK2 is not supported. If you would like to sync something for late joiners, the intended method will be to use variables.

Event Comment

EventComment

Just like at the top of the CyanTrigger, Events can also have comments. You can click the two slash button to edit the comment on an event. You can also use the right click menu or more options button and click the "Edit Comment" option to edit the Event comment.

Event Options

EventOptions

Some options that can be performed on events are hidden in an extra menu. You can access this menu by clicking the More Options button or right clicking within the event.

Event Inputs

By default, every event has the delay input. This delay is the same as in SDK2 in that the actions will only execute after the delay in seconds. With custom events, users can add extra input options. Some events will also provide variables that you can use in your actions.

CustomEventEditor

Here is an example of a user defined custom event which is a variant on OnTriggerEnter. This custom event defines an input, a list of GameObjects, and provides a variable that you can use in the actions, onTriggerEnterOther which is of type Collider.

Actions

Adding Actions

ActionList

There are 6 buttons at the bottom of the Action List for adding new or removing actions.

  • "SDK2" - Add a new Action, selecting from a list of options similar to what SDK2 provided. This is intended to help those who don't want to fully explore everything in Udon.
  • Star - Add a new Action, picking from the list of favorite actions. This list is custom and can be set by the user in the CyanTrigger settings.
  • Plus - Add a new Action, picking from the list of all possible actions provided by Udon and Custom Actions created by users.
  • Shapes - Add a new local variable action.
  • Two Page - Duplicate the selected actions.
  • Minus - Delete the selected actions.

Action Editor

ActionEditor

When editing an action, the input options will display with the action. This means you can expand and edit multiple at once. The box to the right of the action list will expand or contract the action editor for that action. In the example, you can see one action expanded to show the options and inputs. The variant selector is the first option and then the inputs into the action are listed. Some Actions have multiple variants. Variants have the same action name, but different parameters.

Action Inputs

VariableInputs

With CyanTriggers, action inputs can be either a constant value or a variable. Constants will never change, while variable inputs depend on the data in the variable, which may change with different executions of the event. In the example, the int.Addition action has three inputs. The first input and second input give the option between selecting constant input or variable input. The first uses a variable called MyInt. The second input uses a constant value of 5. The third input does not provide an option to select constant or variable, but is limited to only variable. This is because the input type is an "out" input. Variables are required for any "out" inputs as data will be stored from the results of the action, into that variable.

Action Comments

NullInputs

Similar to Events, each Action can have a comment to add information. You can add comments to Actions by right clicking the Action and selecting the "Add Comment" option.

Null Inputs

NullInputs

When an Action has an input without a value or is set to variable but no variable is selected, an orange box will appear around the action. This is orange box is a warning to know that one or more of the inputs are potentially empty or invalid.

Action List

The Action List supports selecting multiple actions. You can duplicate, delete, and even move around all selected actions.

DragReorder

Dragging to move actions can even be done across different events, on the same CyanTrigger or even to a CyanTrigger on another object.

DragBetweenEvents

Some actions are special in that they allow other actions to be nested under them. Actions that support nesting will show an arrow before the Action Label. Check Special Actions for more information on actions that support nesting and other special actions.

NestedActions