PhaxeNor's Examples (Graph & U#)

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.

OnDisable
image

OnTimer

Value can also be synced, that way it will happen at roughly the same time for everyone.

Please note that this example will run every 5 seconds. If you want it to stop after the first time, either disable the gameObject this is on or add a bool check.

1 Like

OnTriggerEnter
OnTriggerExit - Replace OnTriggerEnter with OnTriggerExit

Player Settings with Collider for On Trigger event.

Using this set up, you can use the OnTrigger related stuff above and check if the name matches PlayerCollider and do something if that is detected (This detection is local)

DOWNLOAD

UdonGraph Prefab
UdonSharp Prefab

Hello,

I am trying to use your teleport code, but, it is not bringing me to the location I want the player to be teleported too. It is either throwing someone back a few yards or forcing someone into the door itself, the place where the collider is. I have a whole other room i am hoping to get people too.

So, can you explain in why the code is not sending anyone too the specific parameters?

Thank you

And, what is vector 3 and can i change that at all?

You have to set a target in the Inspector window. There will be a field called “Target”, and you just drag the gameobject that’s in the position you want the target to teleport.

Vector3: https://docs.unity3d.com/ScriptReference/Vector3.html

Hello, and i did that,but, it is just sending me away from the door itself. By just a few yards at most. Could it be possible to be out of range for a teleport?

You can teleport to the void if you want to. Screenshot what you got (graph and inspector)

telly insp.

The timer doesnt work for me D:

You’re not updating the deltaTime variable. So every update it will start on zero.
Make sure you do a SetVariable in the false flow of the branch to update the deltatime value for the next update.

Which I forgot to add in the example :grimacing:

I can’t seem to figure out where in the transform variable I need to put the coordinates. it just teleports me on top of the cube I made.

You need to drag the gameObject that is positioned where you want the player to teleport to into the Target field in the Inspector where the graph is.

image

Thank you so much! that helped a ton.

1 Like

Thank you, this is very helpful and I much appreciate you kindly posting some examples and assisting others.

1 Like

On trying to convert a trigger script to Udon. Does Component and Enable matter in this case. If so then how would you convert this.IMG_8676
If you do manage to convert it. Can you explain what each part of it does?