- Home /
Question by
Riiich · Sep 17, 2021 at 01:43 PM ·
vrsocketinteractable
"Clone" an XR object on pickup
The VRTK Snap Drop Zone
has a property called "Clone New On Unsnap" (https://vrtoolkit.readme.io/docs/snap-drop-zone). It basically means if you pick up something from a socket, you pick up a clone instead of the original that's attached to the socket.
Does Unity's built-in XR system have something similar?
Comment
Best Answer
Answer by Riiich · Sep 17, 2021 at 04:24 PM
Ended up creating my own solution using the built-in XR Socket Interactor
using the Select Exited
event
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class CloneSocketObject : MonoBehaviour
{
[SerializeField] GameObject clonePrefab;
public void CloneInteractable(SelectExitEventArgs args)
{
XRBaseInteractor socket = args.interactor;
GameObject gameObjectClone = Instantiate(clonePrefab, socket.transform.position, socket.transform.rotation);
socket.GetComponent<XRSocketInteractor>().StartManualInteraction(gameObjectClone.GetComponent<XRBaseInteractable>());
}
}
xr.png
(52.1 kB)
Your answer
Follow this Question
Related Questions
How to make audio interact with visual in VR? VRTK 0 Answers
XRGrabInteractable track velocity, not position 0 Answers
VRTK: Gameobject will not become child 0 Answers
Cant get Attach Transform of interactorObject. 1 Answer
SocketPolicyServer Issues 2 Answers