-
Notifications
You must be signed in to change notification settings - Fork 5
Misc Behaviours
A collection of small, general / single purpose built behaviours
Before using any of these behaviours, check the general usage guide.
-
Parameters list describes all the public variables and settings exposed to you, some of them are UI only, so if you're planning to modify them via other udon behaviours - make sure to check the actual
UdonBehaviour
component on the same object. -
Events list describes all the exposed custom events the component expects to recieve. Most things that are expected to be "Triggered" in some way usually have a
Trigger
event exposed. The full list of events can also be seen at the bottom of the behaviour UI with a convinience button for you to use while testing in editor. - Usage / Examples is a freeform section with some personal usage advice and other notes
You can generally split the things below into Triggers
and Actions
(plus some extras), one group captures player interactions in some way - the other performs some actions in response.
Most of the time you would add a bunch of Universal Action
behaviours to the scene and then trigger them from all the different trigger behaviours listed on this page. But this system can also easily interact with other things in your world outside of Udon Toolkit! So don't feel limited by the Universal Action
and use the Udon Events
list with other behaviours to mix and match stuff.
Tracks local player's Tracking Data source or a Bone transform and copies it over to the target transform
- Track Bone: Switches between tracking a Tracking Data source (Head/Hands) and tracking Bones
- Bone: Only visible when Track Bone is checked. Specifies which Bone to track
- Tracking Target: Only visible when Track Bone is unchecked. Specifies which Tracking Data target to use
- Target Transform: Transform to copy the tracked Bone / Tracking Data position and rotation to
- Track Position: Specifies whether the position should be copied
- Track Rotation: Specifies whether the rotation should be copied
- Tracking Correction: Allows to apply an extra X/Y/Z rotation to the transform after copying it over
- Follow Main Camera: For editor use only. Makes the object follow the main camera, helpful for editor testing
The basic usage of this component is intended to be things like attaching objects to player's hands, head or both.
Makes an object follow another object with smooth interpolation
- Source Transform: The source of position and rotation to copy from
- Target Transform: The target of position and rotation to copy to
- Lerp Position: Specifies whether the position should be interpolated (smoothed) or instant
- Lerp Rotation: Specifies whether the rotation should be interpolated (smoothed) or instant
- Lerp Speed: A speed with which Target will achieve Source's position and rotation
- Ignore Rotation: Specifies whether to copy rotation or completely ignore it
Generally good feeling lerp value for scene objects seems to be at around 5-15, for player attached object (like with Universal Tracker) higher values are recommended.
Ignore rotation can be used in cases where you want to have the object look at a particular spot or generally not rotate with the Source object. Thins like Rotation / LookAt or Aim constraints come to mind as good combinations.
The bread and butter of any world reactivity, allows you to perform various actions in response to an incoming Trigger
event. Think about it as a VRC SDK2 Triggers Lite
-
Active: Determines if the behaviour is running, since toggling game objects on and off only means they won't run
Update
- Fire After Delay: Object must be enabled at all times for this to work. Specifies whether the triggers should be fired after a delay
- Delay Length: Only visible when Fire After Delay is checked. Sets the delay length in seconds
- Fire Animation Triggers: Specifies whether the Animation Triggers should be executed
- Animator Triggers List: A list of Animators and Triggers to fire, you can specify the same Animator multiple times to fire multiple triggers
- Fire Udon Events: Specifies whethere the Udon Events should be sent
- Networked: When checked - Udon Events will be sent to targets set in Network Targets
- Network Target: Specifies who to send the network events to
- Udon Events List: A list of Udon Behaviours and Events to call
- Fire Object Toggles: Specifies whether to Enable/Disable/Toggle objects from the Game Objects List
- Game Objects List: A list of Game Objects to Enable, Disable or Toggle
- Fire Audio Events: Specifies whether to Play the soud clips provided in the Audio List
- Audio List: A list of Audio Sources and Audio Clips to play through them
Make sure to only use Networked option when executing this trigger locally, e.g. via a UI Button, otherwise you might cause oversync
- Trigger: Triggers this Universal Action
- Activate: Activates the behaviour so it will react to Trigger events
- Deactivate: Deactivates the behaviour so it will no longer react
- Toggle: Toggles the active state, provided for convinience
Universal Action will probably be the most used behaviour in your world, as its basically a simplified trigger from SDK2. It is not as deep as the original triggers, though, so you are expected to combine it with more specific behaviours from Udon Toolkit or other places to extend its functionality.
This component makes it pretty trivial to do things via UI Buttons simply by calling a SendCustomEvent
on it with Trigger
as the event name.
An example of setting up a mirror toggle via UI Button would look like this:
- Add a VRC Mirror prefab, disable it to save performance by default
- Add a
Universal Action Controller
to the Mirror object - Make sure
Active
is checked, checkFire Object Toggles
, click on theGame Objects List
and clickAdd Element
- Drag your Mirror object into the empty field, select
Toggle
in the dropdown on the right - Add a
UI -> Button
to your scene, set theRender Mode
toWorld Space
and scale it way down and place it where you want - Add a
Ui Shape
component to the Canvas - Change canvas layer to
Default
- Click on your Button inside the Canvas and add a new
On Click()
event by clicking the small+
icon in the bottom right - Drag and Drop your Mirror object into the empty field that appeared
- In the dropdown next to
Runtime Only
selectUdonBehaviour -> SendCustomEvent
(its all the way at the bottom) - Type
Trigger
in the text field
You're done! Now you can toggle your mirror via UI button in Udon.
The major thing to note here is to make sure that the component and the game object its on is always enabled if you're using the Delay
parameter, otherwise it will never fire as the Update method will never be called.
Sends events to udon behaviours based on the player's name
- Active: Determines if the actions will be executed on Start
- Actions List: A list of Udon Behaviours and Events to send to them
- Trigger: Executes the logic again, you will probably want this to be called from the network to run for everyone again
Ever wanted to have something special activate only for particular users? This behaviour does exactly that! Combine this with Universal Action to do something special for that user, or specify behaviours of your own.
If sending events once isn't enough - you can use the Trigger
event to fire it again.
A "proxy" of sorts that expects a "Trigger" event and sends Networked events to specified behaviours
- Event Target: Specifies who to send the events to
- Udon Events List: A list of Udon Behaviours and events to send to them
- Trigger: Fires the events on the provided behaviour over the network
Think about this as a very slimmed down Universal Action that can only send events to other Udon Behaviours. While its not that useful on its own - it might serve as a nice layer between UI Buttons and some other behaviours that you want to call for everyone in the room, or their owners.
You can achieve the same things by using Universal Action and checking the Networked
checkbox, but it is heavier as is, so this separation is just a way to simplify things.
Sends events to other behaviours when an object enters and exits a trigger collider
- Active: Specifies whether the triggers will fire, as just disabling the object doesn't stop it from reacting to enter/exit events
- Collide With: Specifies the list of layers to filter out the objects you don't want to react to
- Networked: Specifies wether the events should be sent over the network or only fired locally
- Network Target: Specifies who to send the network events to
- Enter Events List: A list of Udon Behaviours and Events to send when the correct object enters the trigger collider
- Exit Events List: A list of Udon Behaviours and Events to send when the correct object exits the trigger collider
- Activate: Activates the behaviour so it will react to objects
- Deactivate: Deactivates the behaviour so it will no longer react
- Toggle: Toggles the active state, provided for convinience
This is an equivalent of VRC SDK2's Trigger Enter
and Trigger Exit
triggers with some small exceptions due to current Udon limitations (as of July 2020).
The UI will try to guide you around the main pitfalls, but in short - you should follow this small set of rules to have everything working as expected.
- Setting
Collide With
to eitherPlayer
orPlayerLocal
on one of the default layers - won't work, as vrchat doesn't allow us to check whether the player is local or remote. One of the solutions to this is to create a new layer in unity, make it collide with either of these and set theArea Trigger
to it - Generally speaking you would want the
Area Trigger
to be on theMirrorReflection
layer to avoid some weird vrchat issues, unless you have a case where you need a custom layer, e.g. like the one described above - Do not use the
Networked
option ifCollide With
is set toPlayer
, as this will make everyone send events to everyone all the time, causing oversync and possibly desyncing people in the instance. A good rule of thumb when it comes to things like this goes like: "if everyone can see object X enter trigger Y - you can keep everything local"
Makes something react to player interaction, VRC SDK2-style
- Active: Specifies whether the object from being interactible
- Interaction Text: Sets the text shown when hovering over the object
- Proximity: Sets the interaction distance of the object
- Networked: Specifies whehter the Udon Events should be sent to other players
- Network Target: Specifies who to send the Udon Events to
- Udon Events: A list of Udon Behaviours and Events to send
- Interact: Sends events to provided Udon Behaviours
- Activate: Activates the behaviour so the object will become interactable
- Deactivate: Deactivates the behaviour so the object will no longer be interactable
- Toggle: Toggles the active state, provided for convinience
This is an almost one to one equivalent of the VRC SDK2 Interact
trigger. Use in combination with Universal Action
to do something when user clicks on an object.
Activate
/Deactivate
/Toggle
events will also allow you to disable the highlight on the object, if you don't want it to be interactable anymore.
Sends Events to Udon Behaviours if a target object crosses a particular threshold and disables itself (by default
- Active: Toggles the threshold checks on and off
- Target: The target object to observe
- Cross Mode: Makes this trigger run every time the Target crosses the threshold (either way), also makes it so the trigger doesnt disable itself after the threshold is crossed
- Test Mode: Specifies whether the trigger will fire if ALL or ANY of the specifies boundaries are crossed
-
Boundary List: A list of conditions and coordinates to check against, e.g.
Above Y: 10
will make the trigger fire events if the Target gets above 10 units on Y coordinate - Networked: Specifies whehter the Udon Events should be sent to other players
- Network Target: Specifies who to send the Udon Events to
- Udon Events: A list of Udon Behaviours and Events to send
- Trigger: Fires the events specified in the Udon Events list
- Activate: Activates the behaviour so it will start checking the boundaries
- Deactivate: Deactivates the behaviour so it will no perform any checks
- Toggle: Toggles the active state, provided for convinience
🚨 Found an issue? File an issue
💬 Join the Discord server
🕶 Support the project if you found it useful