Object Reset Button
Reset a movable object back to a saved transform when interacted with.
Category: Interaction Systems
UdonSharp Script
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class ObjectResetButton : UdonSharpBehaviour
{
public Transform targetObject;
private Vector3 startPos;
private Quaternion startRot;
private void Start()
{
if (targetObject == null) return;
startPos = targetObject.position;
startRot = targetObject.rotation;
}
public override void Interact()
{
VRCPlayerApi localPlayer = Networking.LocalPlayer;
if (localPlayer == null || targetObject == null) return;
Networking.SetOwner(localPlayer, targetObject.gameObject);
targetObject.SetPositionAndRotation(startPos, startRot);
}
}
Setup
- Add script to a reset button with
VRC_Interactable. - Assign pickup or movable object to
targetObject. - Enter play mode and test pickup movement then reset.
Extra Tips and Troubleshooting
Tips and Tricks
- Use one reset button per zone for user convenience.
- Label reset buttons clearly if many interactive props exist.
Troubleshooting
- If object does not reset, confirm ownership can be set and target transform is correct.
Related Content
Prefab Setup Notes
Import the prefab or script into a throwaway test scene before adding it to a live world. Confirm inspector references, ownership behavior, sync, triggers, UI hooks, and audio or object links before moving it into the production scene.
Testing Checklist
- Test once as a local player and again with a second client or late joiner if the behavior can affect more than one player.
- Confirm ownership, sync, trigger zones, UI references, and audio or object references are assigned intentionally.
- Check desktop and VR interaction distance so players can actually use the feature in context.
- Keep a backup of the scene before changing prefabs, UdonBehaviours, or serialized references.
