PhaxeNor's Examples (Graph & U#)

Recreation AutoCam

Add a camera and add this graph to it.

Example asset may be broken. Not had the time to update it yet!

Player Teleport (Basic)

Make a gameobject with a collider on it and add the graph to it. Then in the inspector set the location you want to teleport to in the public transform variable

Udon Graph

UdonSharp

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;

public class TeleportPlayer : UdonSharpBehaviour
{
    [SerializeField] Transform target;

    public override void Interact()
    {
        Networking.LocalPlayer.TeleportTo(target.position, target.rotation);
    }
}
Old Graph

Check if object exists and is not to be destroyed

If ( gameObject != null && gameObject.name != “ToDestroy” )

Check if gameObject exists and that the name is not equal to ToDestroy
Keep in mind that == / != checks are slow

Graph Code

AMVVyWrbQBh+FTNnjZlNoxlDLlkooZAUslyKEbO6ahUp1dLWuH6yHvpIfYWO7NhpLDvokKQIBP+v0Wi+7defX78X4JvKWwcmHxfAt3l+oe5CAW6KrJmfFbOscO9C51J/dqYZp+nMNels20jTvetABNrMhl08MoxiJmEiZQIZ8hhKiy20XsWGK+Ys8mHxfVlnTVYWYLIAP8AEEobGKAJzMGFijJYRKErrbs5P63BKAKYR8Hn5/aGerp/ediDqFYq2O9L6ILdraAuQFXWjCuPOT8Gk27BuqqyYPTwGYDldRoPgn31tVV6n6dW8btzdhoR1dVyWuVPFFjwnKuFaYCgI8pA5waDQwkBCnTGaeUtj2QffIV5Bh4L1sA/h8ycKm1rsvZCJhcoSB5mRGCrnUTgKZkwhzrRHYeFTKoGXXCFsCESJM5Bh5qFQnECsHdUYUU48Bi9DePQyOp2U4YX0IjS2tA+Bvs9zZEM8pmSX+OctN9Q8XXaK0NgY5moF7tEvNBaMIwQVFhKyOJFQJAJBGyNhiLBSyD1hofxwVAba5S0C9S/iXo7W7afFgVANsmg/VJ2kB1M1hPhVqnbzQrmTlFALPU44ZFooKDCnwUveOSG1toT/z7ysKRyvGY1Gd7UpqzzT0ejWVXVg5yhw0V3R6KTNm7ZyR4Vrm0rl0ehDq/PMvHfz6/KLK450kgTLxBxLyhwS8ud1eerCx8r5IakfhAtal/dpiKld6aHyy2pH2p3qgO6MaR2yK6F0BkPmEYda0OBsyohFkhuhxHO670nHkPm8kn2I514pRi80JvdIclOoan7hZqqja1eSAyLoOFbIagZjqwJjiQqjVcYY0iTcBU4EI3tG66MIOOY9FYYI+0Yz6rgKqz9t0Q5Kdw9tGBybUZP0/iODGHw1tNPlXw==


One less node, but instead of TRUE being the output flow, it’s FALSE that is used.

Graph Code

AMVVyW7bMBD9FYNnMeAylEgDuWRBERRICmS5FIZAkSNXrSKlltTWcPxlPeST+gull7iNnRg6JC108Qwpet5G/fr5MCPfbNkhGX6ckbwry3N7GwpyXRXt9LQaFxW+C52L7DO69iBNx9im400jTZ/dRyLSFT6cwhPn4iROqHXcUZBeU229pLlX3iYMrQQIm+/qpmiLuiLDGflBhlQAO2ARmZIhiPBrHpGq9nh9dtKEMQkZRSQv6+/rerRavVmgaJYwusVMq0luVthmpKia1lYOz07IcHFg006KarxeJmQ+mke98J9+7WzZpOnltGnx9pGFVXVU1yXaaoNeKJMpFIr6mCEFxmOqVQ6UKQHeY4KY57voQa+xC613sPch9J6FQ0FJz9EKarhLKGCuqbWKU6+NFAbDEl9sfEolkcxAbJykTOQ5hZgxahKnqYuzHLTzSomYvA7h0evodFyHF9Lz0NjQ3gf6c6YTj8QrBtvE77dcX/MswlOFxqNhLpfgNoMnKCzmsaM8B0/BW041cE8zxrkwwgnkYndwGe/JSk+//ItE/Q15J0ir9tPihVT18uhuqqTYE6s+zC9jtR0YzjxkmYwpZ6gpmCQJEdeWggIjjGeOg/6fgVlReLBiNBrcNq6elEUWDW5w0gR2DoPTF080OO7KtpvgYYVdO7FlNPjQZWXh3uP0qv6C1WGWJFY5FXMjAZk291f1CYY/q6cvSb0WLmhd36Uhp36phy0vJlvSblUv6O6UF0ZKRaVCoJBAsDJISWOZCWulAxGbfbo/F48+N/RS9z6me6McvdJFeTQJuz/9+TL3Me4Om4lme1LUR6E3u2xG898=


To avoid the lifetime check that the underlying code does in Unity, you can run ReferenceEquals which will just check if the object exists.

Graph Code

AN1Uy27UMBT9F6/nVnb8nmVphbopEqjdoCry43oImiZlkgFGQ7+MBZ/EL+C0JWonZRRQixCryPa91z7n5JzvX79tyUe3XCOZv92StF4uT91lXpA3m7bDy1f+PYbuoCxfY8IV1gGPP6zdsi3L++cPF3erw6ZZoqvJjKyrmAcahZgk4yCTZyAKY8FKKYAHrpMUjCvJcvFV01Zd1dRkviWfybwQB3RGNmSulTmg1zNSNxHPTo7a/F4iki6U0hwUSgPCUAZexwBRC5Fvo1Rw/oXmoUWU1FLugVkaQEQnwUSVwEYWEPMQZkUuvJiRtGw+/RxPlTI0BgRFVQShOYJ3KUJ0yrMQCkWD63v6J533HLY3JK7rqtvccnF+y+yWVHXbuczeyRGZ9yjablXVi7tjQq5nf9Z20TfeE+2sn3FcL6oaX+adQb0FduVi2CjLR+sGpabQOlYKOCv2aLVD7tPQtov/RZMbytO8MYCZIv1jYCi9A2NksQtmP5TdRz2wQxajucr8u9XmFBeuv3LHML/yj+JOIo0OaOASBIoIxjgE9AmjFJ5q9QgQrgdR7AjHJE+OfPE80h2ucvW7Ae0k743Qaj6gNXSEdgqDfwntk6dr79lgmQVtuYJs0wDWewfJZHDBpcAjjvkaHGvF2LHGx0IYbcBbl0dme4O11oNgPtroGVUm3qQrp4XKlkqgkytAWC7ACEQImhkjZMrfME7XmISm0WQNaIG5K1hwLgrQQeTZhZfOi/8xXafQujdds8D/TLpOkX5vumalR0b9vXjdCY5Jv9WemLRqHBzPxO7F9Q8=


3 Likes

Toggle Object (Single)

Udon Graph

Udon Sharp

using UdonSharp;
using UnityEngine;

public class ToggleObject : UdonSharpBehaviour
{
    [SerializeField] GameObject objectToToggle;

    public override void Interact()
    {
        objectToToggle.SetActive(!objectToToggle.activeSelf);
    }
}
Old Graph



Toggle Object (Advanced)

Udon Graph

Udon Sharp

using UdonSharp;
using UnityEngine;

public class ToggleObjects : UdonSharpBehaviour {

    [SerializeField] GameObject[] objectsToToggle;

    public override void Interact()
    {
        foreach(GameObject go in objectsToToggle) {
            go.SetActive(!go.activeSelf);
        }
    }
}
Old Graph

1 Like

Player "Mods"

These settings can be adjusted on the fly at any time. Simply get the player and set the value.

Udon Graph

Udon Sharp

using UdonSharp;
using VRC.SDKBase;

public class PlayerMods : UdonSharpBehaviour
{
    VRCPlayerApi localPlayer;

    void Start()
    {
        localPlayer = Networking.LocalPlayer;

        localPlayer.SetJumpImpulse(3);
        localPlayer.SetWalkSpeed(2);
        localPlayer.SetRunSpeed(4);
        localPlayer.SetGravityStrength(1);
    }
}
Summary

1 Like

On Player Joined / Left Events

Old Graph

OnPlayerJoined example

OnPlayerLeft example

2 Likes

Looks good! Should include more specifics like Player Teleport (Only if the Player themselves collide)

At some point I will yeah, it does require a bit more set up to do than just teleport the player when it enters a trigger zone.

1 Like

maybe im just dumb but i cant get the teleport to work right i just teleport to X0 Y0 Z0 and can change it

Can you please post a picture of your graph?

i copied your graph but i cant figure out how to change the spawn

You have to set the target in the inspector of the Object that has this graph

For teleportation. Should I just run into the object or just use it as a button.

For this one you have to put it on a object or button. I am currently writing one for a more advanced version

Let me know when it’s done so I can be able to use it with buttons or walking into the object.

You can already use this on buttons. Use the Interact method when setting up the button target.

OnEnable example
Custom Example

OnKeyDown

OnKeyUp

OnDestroy

OnDestroy is called when the scenes switches or the game is shutting down.

Best example for this would be when we get persistent storage, you’ll use this to make sure the data is saved as the user is leaving.