PhaxeNor's Examples (Graph & U#)

If some of them are similar to each other and if I can use the same code for them. Let me know.

Sorry if it sounds like to much. But then we are discovering what Udon could do.

Doing updates to all the examples with the new Udon Graph layout (Old graphs are still there)

Ahhh this explains why my UDON sharp script crashes after a while, I am guessing the player accidently collides and causes the exception. I dont suppose you have the UDON sharp version of this check.
I am currently trying to do “Nothing” when a player is inside the collider, By wrapping it with a If (other.transform != null)… the script still seems to crash after a while (I am guessing this is because a player has entered the collider)

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

public class BeltMove : UdonSharpBehaviour
{
public GameObject track;
public Transform Startpoint;
public Transform Endpoint;
public Transform HidePoint;
public GameObject TargetPosition;

public float Speed;
private void OnTriggerStay(Collider other)
{
    if (other.transform != null)
    {
    other.transform.position = Vector3.MoveTowards(other.transform.position, Endpoint.position, Speed * Time.deltaTime);
    }

    if (other.transform.position == Endpoint.position)
    {
        other.transform.position = HidePoint.position;
        other.transform.position = Startpoint.position;
    }
}

}

When checking against null, you should do return instead.

if (other == null) return;

This will prevent it from crashing. It crashes now because you’re on not doing the not equal check in one if statement, but not the other, which is where it crashes.

1 Like

Brilliant. ! thanks, I also looked at getting round this by creating a “non player” colliding layer in the physics setting and assigning that to the object with the collider. (effectively the player cant collide with it) But this is a much more elegent way to handle it in the code (rather than the “Sledge hammer” approach. Many thanks !!

Really useful stuff, thank you!!

RECOMMENDATIONS:

  • (QoL) - The Udon Graph code would be useful for folks who’d like to copy and paste! :slight_smile:

NOTES:

  • Your teleport script only works for VR users. PC users will not be able to interact with the teleport object.

REQUEST:

  • Any way to whitelist users from a specific teleport / interactive object?
    E.g Only usernames from this list may activate object. (This could be a teleport, or open a certain door).

For the graph code, I can add that again. But this post was created when things kept getting changed around. Breaking any copied code.

The teleport script not working you have to fill me in on.
This is a basic script that I use and have tested with both desktop and VR, which both worked.

As for the request, that is something I can provide yeah!

But other than that, thank you for the comment

Oh sorry, hadn’t thought about that! Must be a lot to maintain! Yeah, recently just been through a big change - cant imagine how many changes will be in the next year!!

It may be me, then in regards to the teleport. I thought maybe “interact” was exclusive to VR, and needed “click down”, but I’ve just tested and that didnt work either. My object doesnt seem to highlight so I’ll put that down to my fault!
Works perfectly in VR, though.

Perfect, I think that would be pretty awesome for those with Patreon supporters, who want to give them private access to things.

Thank you again for the time you take to do these things!! It’s awesome!

1 Like

Interact is part of the VRChat code, which takes care of making sure that it will work for both VR and Desktop. If you use this on a default cube, and it still don’t work on desktop, then it’s on VRChat end.

So I retested on a plain cube and it works absolutely fine. I apologise profoundly!

Not sure what happened but entirely my fault!

Thank you again for your awesome nd continued support & dedication to this!

How would the Player Joined/Left script look if you wanted an audio clip to play when someone joins or leaves the map? Sorry to ask a dumb question, still trying to learn here.


Something like this. All depending what you’re specifically after, but this is the basic.

2 Likes

Thanks! 1 more question, if you don’t mind answering it. When it comes to the teleporting using the game object as a reference, I go down to public variables and it says “target not defined editor for type of System.Object” But I copied the graph that you posted. Did I skip a step or what?

My bad, change the quote to “target no defined editor for type of System.Object”

Got to make sure it’s Transform and not GameObject

How would a U# Event of “OnPlayerJoined” look like?
Cant find anything online and i get an error “Event _onPlayerJoined must have the correct argument types”
because i dont know how to use the VRCPlayerAPI on this Event correctly. Thanks!

public override void OnPlayerJoined(VRCPlayerApi player) {
   // Code
}
1 Like

Wow! That was fast! Thanks man! :grinning: :+1:

Ah I see, thank you so much mate!!!