Turning my old SDK 2 triggers into UdonSharp

Hi, I make the most popular DND map in VRChat and I maintain the largest VRChat DND discord community. I am learning UdonSharp and I want to convert my SDK 2 worlds to it.

In order to do that, I’ll need help with various triggers that my worlds use. I am even willing to pay someone for tutoring (if you have the time).

At this moment I know how to use Unity 100% and implement buttons with Udon and write code in UdonSharp, then test it in the world. I don’t know how to get the following triggers to function using udonSharp:

Trigger #1
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Enable Object (1)

Trigger #2
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Disable Object (1)

Trigger #3
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Enable Object (1), Enable Object (2)

Trigger #4
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Enable Object (1), Disable Object (2)

Trigger #5
Input: OnInteract
Broadcast: Local
Output: Enable Object (1)

Trigger #6
Input: OnInteract
Broadcast: MasterBufferOne
Output: Enable Object (1)

Trigger #7
Input: OnInteract
Broadcast: Master
Output: Enable Object (1)

Trigger #8
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Enable an Object at Random [(1), (2)]

Trigger #9
Input: OnInteract
Broadcast: Local
Output: Enable Object (1)
&
Broadcast: AlwaysBufferOne
Output: Enable Object (2)

Trigger #10
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Destroy Object (1)

Trigger #11
Input: OnInteract
Broadcast: AlwaysBufferOne
Output: Teleport Object (1)

Trigger #12
Input: OnInteract
Broadcast: Always
Output: Spawn Object

Trigger #12
Input: OnInteract
Broadcast: Local
Output: Animation IntMultiply (“value”)

Trigger #13
Input: OnInteract
Broadcast: Local
Output: Animation IntAdd (“value”)

Trigger #14
Input: OnInteract
Broadcast: Local
Output: Animation IntTrigger (“value”)

Trigger #15
Input: OnInteract
Broadcast: Local
Output: Animation IntBool (“value”)

Trigger #16
Input: OnInteract
Broadcast: Local
Output: Set UIText (“value”)

Trigger #17
Input: OnEnable
Broadcast: Local
Output: Enable Object (1)

Trigger #18
Input: OnDisable
Broadcast: Local
Output: Enable Object (1)

Trigger #19
Input: OnDisable
Broadcast: Local
Output: Enable Object (1)

Trigger #20
Input: OnPlayerEnter
Broadcast: Local
Output: Enable Object (1)

Trigger #21
Input: OnPlayerExit
Broadcast: Local
Output: Enable Object (1)

Trigger #22
Input: OnEnterCollider
Broadcast: Local
Output: Enable Object (1)

Trigger #23
Input: OnExitCollider
Broadcast: Local
Output: Enable Object (1)

Trigger #24
Input: OnPickupUseUp
Broadcast: Local
Output: Enable Object (1)

Trigger #25
Input: OnPickupUseDown
Broadcast: Local
Output: Enable Object (1)

Trigger #26
Input: OnInteract
Broadcast: Local
Output: Teleport Player

Trigger #27
Input: OnInteract
Broadcast: Local
Output: Sit Down in Chair

Trigger #28
Input: OnInteract
Broadcast: AlwaysBufferOne (1) & Local (2)
Output: Enable Object (1) & Enable Object (2)

If we answer all 28 of these questions then we can for sure make any world in VRChat possible!

The problem with Triggers to Udon is that each world does things differently and it makes it difficult to create a “Prefab” for these things.

How things were done in Triggeres shouldn’t be encouraged but rather shown how to do it in a better way.

Take a common toggle system; You would create two gameObjects with a interact trigger on it. They both also show the current state, on and off.

With Udon this could be done with a single gameObject instead.
I think this is a better way to show people how to do it.

But as I said, I can post the basics for these as you’ve written them here.

Example for better interact - Synced

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

public class OnInteract : UdonSharpBehaviour
{
    [Tooltip("GameObjects you want to toggle")]
    public GameObject[] objectsToToggle;

    [Tooltip("The enabled state. Toggle this to change between enabled or disabled start state.")]
    private bool _isEnabled = false;
    [UdonSynced] public bool isEnabled = false;

    [Tooltip("The button color states.")]
    public Color onStateColor = Color.green, offStateColor = Color.red;
    
    private MeshRenderer _meshRenderer;
    private MaterialPropertyBlock _propBlock;

    /// <summary>
    /// Start will run to ensure the default state.
    /// </summary>
    private void Start()
    {
        _propBlock = new MaterialPropertyBlock();
        _meshRenderer = GetComponent<MeshRenderer>();

        _isEnabled = isEnabled;

        UpdateState();
    }

    /// <summary>
    /// On Interact, take ownership, set state, and update locally.
    /// </summary>
    public override void Interact()
    {
        Networking.SetOwner(Networking.LocalPlayer, gameObject);
        _isEnabled = !_isEnabled;

        UpdateState();
    }

    /// <summary>
    /// Update State for the gameobjects
    /// </summary>
    private void UpdateState()
    {
        foreach(GameObject obj in objectsToToggle) {
            obj.SetActive(_isEnabled);
        }

        _meshRenderer.GetPropertyBlock(_propBlock);
        _propBlock.SetColor("_Color", _isEnabled ? onStateColor : offStateColor);
        _meshRenderer.SetPropertyBlock(_propBlock);
    }


    /// <summary>
    /// Owner update synced variable
    /// </summary>
    public override void OnPreSerialization()
    {
        isEnabled = _isEnabled;
    }

    /// <summary>
    /// Remote update local variable and update state
    /// </summary>
    public override void OnDeserialization()
    {
        if(isEnabled != _isEnabled) {
            _isEnabled = isEnabled;
            UpdateState();
        }
    }
}