Check if an object is grabbed
Hello guys. I can't find a way to check if an object is grabbed or not, a boolean that is true if it is grabbed and false if it is not. The attached image is the components that the object that I want that variable to have. I'm using Oculus sdk Integration in Unity 2020.3.10. Any help is appreciated. Thank youSolved25KViews1like16CommentsBug report: Grabbable not positioning properly when force releasing then force selecting
Unity Version 2022.3.40f1 Meta XR Interaction SDK Version 69.0.2 I am currently using hand tracking with a Grabbable interactable. The interactable is a gun that I do not want the player to be able to drop so I use ForceSelect on spawn to bring the gun to the players hand. I want the player to be able to swap hands by grabbing the handle of the gun so I have a second mirrored Hand Grab Interactive with both max interactors set to 1. The main Grababble script is also set to max grab points 1. I can grab the gun with my left hand and swap fine. It is when I then grab the gun back from my left hand when the Grabbable then gets set to world point zero, and my gun objec moves around on a pivot from world zero. The only way to fix this is to open the oculus menu then resume, the gun then teleports into the hand it should be in. I reset the local position and rotation of my grabbables because they break when the application loses focus and start pivoting from world zero. This fix works for when I open the oculus menu and return but not for when grabbing back the gun from my left hand. private void SwapHands(eHand newHand) { _secondHandleGrabbed = false; _interactorLeft.ForceRelease(); _interactorRight.ForceRelease(); if (newHand == eHand.Right) { _hand = eHand.Right; _interactorRight.ForceSelect(_handGrabbableRight, false); } else { _hand = eHand.Left; _interactorLeft.ForceSelect(_handGrabbableLeft, false); } _mainGrabbable.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); _handGrabbableRight.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); _handGrabbableLeft.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); } private void OnGunGrabbedLeft(PointerEvent evnt) { switch (evnt.Type) { case PointerEventType.Select: print("grabbed with left"); SwapHands(eHand.Left); break; } } private void OnGunGrabbedRight(PointerEvent evnt) { switch (evnt.Type) { case PointerEventType.Select: print("grabbed with right"); SwapHands(eHand.Right); break; } } private void OnInputFocusAcquired() { _interactorLeft.ForceRelease(); _interactorRight.ForceRelease(); if (_hand == eHand.Right) { _interactorRight.ForceSelect(_handGrabbableRight, false); } else { _interactorLeft.ForceSelect(_handGrabbableLeft, false); } _mainGrabbable.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); _handGrabbableRight.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); _handGrabbableLeft.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); } Edit: Added images for extra contextSolved863Views0likes1CommentGrab objects with weight
Hi, I would like to know if there is a way to make that when I pick up objects they move according to their weight, for example if I pick up a heavy object, when I move my hand the hand tracking should take more time to reach the position of my real hand compared to if I was holding a lighter object, I have looked for multiple solutions but I have not been able to achieve anything yet, I appreciate any help!Solved1.5KViews0likes3CommentsDynamic Grab Colliders
Hey Everyone! I am currently developing an App where I want to Snap Bricks together like Lego. I am using Unity 2022.3.12f1 with the latest Meta SDK (v.65) After Snapping my bricks are organised in a Parent Child relation. I am deactivating the Grab objects of all Children. This obviously leads to the children not being grabbable any longer. Now if I build a parent-child relation in the editor and make the Parent Grabbable the child gets treated like a part of the parent. I can grab it and the whole construct gets grabbed and I can move it. This does not work with my running code. My Expectation is that the GrabInteractors of the Parent also use the Colliders of the Children after I deactivate the Grabbable scripts of the children but this is not the case.387Views0likes0CommentsHow to modify Grabable scripts?
I renamed HandGrabInteractable to HandleLeft and confirmed that the grab functionality is working well. Additionally, I want to save the position when HandleLeft is grabbed and moved, and create a new object at that position. So, I wanted to add a public bool DropDown variable inside the Grabbable script and set DropDown = true during EndTransform(), but it keeps getting deleted automatically. I'm not sure how to solve this issue. Please help. + Additionally, the PointableElement, IGrabbable properties are not enabled. (The font color does not change.) Note : Visual Studio 2022 , Unity 2022.03.20f1,meta XR interaction SDK 63.00 /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * Licensed under the Oculus SDK License Agreement (the "License"); * you may not use the Oculus SDK except in compliance with the License, * which is provided at the time of installation or download, or which * otherwise accompanies this software in either electronic or hard copy form. * * You may obtain a copy of the License at * * https://developer.oculus.com/licenses/oculussdk/ * * Unless required by applicable law or agreed to in writing, the Oculus SDK * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System.Collections.Generic; using UnityEngine; namespace Oculus.Interaction { /// <summary> /// Moves the object it's attached to when an Interactor selects that object. /// </summary> public class Grabbable : PointableElement, IGrabbable { /// <summary> /// A One Grab...Transformer component, which should be attached to the grabbable object. Defaults to One Grab Free Transformer. /// If you set the Two Grab Transformer property and still want to use one hand for grabs, you must set this property as well. /// </summary> [Tooltip("A One Grab...Transformer component, which should be attached to the grabbable object. Defaults to One Grab Free Transformer. If you set the Two Grab Transformer property and still want to use one hand for grabs, you must set this property as well.")] [SerializeField, Interface(typeof(ITransformer))] [Optional(OptionalAttribute.Flag.AutoGenerated)] private UnityEngine.Object _oneGrabTransformer = null; /// <summary> /// A Two Grab...Transformer component, which should be attached to the grabbable object. /// If you set this property but also want to use one hand for grabs, you must set the One Grab Transformer property. /// </summary> [Tooltip("A Two Grab...Transformer component, which should be attached to the grabbable object. If you set this property but also want to use one hand for grabs, you must set the One Grab Transformer property.")] [SerializeField, Interface(typeof(ITransformer)), Optional] private UnityEngine.Object _twoGrabTransformer = null; [Tooltip("The target transform of the Grabbable. If unassigned, " + "the transform of this GameObject will be used.")] [SerializeField] [Optional(OptionalAttribute.Flag.AutoGenerated)] private Transform _targetTransform; /// <summary> /// The maximum number of grab points. Can be either -1 (unlimited), 1, or 2. /// </summary> [Tooltip("The maximum number of grab points. Can be either -1 (unlimited), 1, or 2.")] [SerializeField] private int _maxGrabPoints = -1; public int MaxGrabPoints { get { return _maxGrabPoints; } set { _maxGrabPoints = value; } } public Transform Transform => _targetTransform; public List<Pose> GrabPoints => _selectingPoints; private ITransformer _activeTransformer = null; private ITransformer OneGrabTransformer; private ITransformer TwoGrabTransformer; protected override void Awake() { base.Awake(); OneGrabTransformer = _oneGrabTransformer as ITransformer; TwoGrabTransformer = _twoGrabTransformer as ITransformer; } protected override void Start() { this.BeginStart(ref _started, () => base.Start()); if (_targetTransform == null) { _targetTransform = transform; } if (_oneGrabTransformer != null) { this.AssertField(OneGrabTransformer, nameof(OneGrabTransformer)); OneGrabTransformer.Initialize(this); } if (_twoGrabTransformer != null) { this.AssertField(TwoGrabTransformer, nameof(TwoGrabTransformer)); TwoGrabTransformer.Initialize(this); } // Create a default if no transformers assigned if (OneGrabTransformer == null && TwoGrabTransformer == null) { OneGrabFreeTransformer defaultTransformer = gameObject.AddComponent<OneGrabFreeTransformer>(); _oneGrabTransformer = defaultTransformer; OneGrabTransformer = defaultTransformer; OneGrabTransformer.Initialize(this); } this.EndStart(ref _started); } public override void ProcessPointerEvent(PointerEvent evt) { switch (evt.Type) { case PointerEventType.Select: EndTransform(); break; case PointerEventType.Unselect: ForceMove(evt); EndTransform(); break; case PointerEventType.Cancel: EndTransform(); break; } base.ProcessPointerEvent(evt); switch (evt.Type) { case PointerEventType.Select: BeginTransform(); break; case PointerEventType.Unselect: BeginTransform(); break; case PointerEventType.Move: UpdateTransform(); break; } } private void ForceMove(PointerEvent releaseEvent) { PointerEvent moveEvent = new PointerEvent(releaseEvent.Identifier, PointerEventType.Move, releaseEvent.Pose, releaseEvent.Data); ProcessPointerEvent(moveEvent); } // Whenever we change the number of grab points, we save the // current transform data private void BeginTransform() { // End the transform on any existing transformer before we // begin the new one EndTransform(); int useGrabPoints = _selectingPoints.Count; if (_maxGrabPoints != -1) { useGrabPoints = Mathf.Min(useGrabPoints, _maxGrabPoints); } switch (useGrabPoints) { case 1: _activeTransformer = OneGrabTransformer; break; case 2: _activeTransformer = TwoGrabTransformer; break; default: _activeTransformer = null; break; } if (_activeTransformer == null) { return; } _activeTransformer.BeginTransform(); } private void UpdateTransform() { if (_activeTransformer == null) { return; } _activeTransformer.UpdateTransform(); } private void EndTransform() { if (_activeTransformer == null) { return; } _activeTransformer.EndTransform(); _activeTransformer = null; } protected override void OnDisable() { if (_started) { EndTransform(); } base.OnDisable(); } #region Inject public void InjectOptionalOneGrabTransformer(ITransformer transformer) { _oneGrabTransformer = transformer as UnityEngine.Object; OneGrabTransformer = transformer; } public void InjectOptionalTwoGrabTransformer(ITransformer transformer) { _twoGrabTransformer = transformer as UnityEngine.Object; TwoGrabTransformer = transformer; } public void InjectOptionalTargetTransform(Transform targetTransform) { _targetTransform = targetTransform; } #endregion } } 1.3KViews0likes0CommentsUnity Help Needed: Preserving Object Position After Grab and Instantiating New Object
I renamed HandGrabInteractable to HandleLeft and confirmed that the grab functionality is working well. Additionally, I want to save the position when HandleLeft is grabbed and moved, and create a new object at that position. So, I wanted to add a public bool DropDown variable inside the Grabbable script and set DropDown = true during EndTransform(), but it keeps getting deleted automatically. I'm not sure how to solve this issue. Please help.. + the PointableElement, IGrabbable properties are not enabled. (The font color does not change.) Note: Visual Studio 2022, Unity 2022.03.20f1, meta XR interaction SDK 63.00 /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * Licensed under the Oculus SDK License Agreement (the "License"); * you may not use the Oculus SDK except in compliance with the License, * which is provided at the time of installation or download, or which * otherwise accompanies this software in either electronic or hard copy form. * * You may obtain a copy of the License at * * https://developer.oculus.com/licenses/oculussdk/ * * Unless required by applicable law or agreed to in writing, the Oculus SDK * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System.Collections.Generic; using UnityEngine; namespace Oculus.Interaction { /// <summary> /// Moves the object it's attached to when an Interactor selects that object. /// </summary> public class Grabbable : PointableElement, IGrabbable { /// <summary> /// A One Grab...Transformer component, which should be attached to the grabbable object. Defaults to One Grab Free Transformer. /// If you set the Two Grab Transformer property and still want to use one hand for grabs, you must set this property as well. /// </summary> [Tooltip("A One Grab...Transformer component, which should be attached to the grabbable object. Defaults to One Grab Free Transformer. If you set the Two Grab Transformer property and still want to use one hand for grabs, you must set this property as well.")] [SerializeField, Interface(typeof(ITransformer))] [Optional(OptionalAttribute.Flag.AutoGenerated)] private UnityEngine.Object _oneGrabTransformer = null; /// <summary> /// A Two Grab...Transformer component, which should be attached to the grabbable object. /// If you set this property but also want to use one hand for grabs, you must set the One Grab Transformer property. /// </summary> [Tooltip("A Two Grab...Transformer component, which should be attached to the grabbable object. If you set this property but also want to use one hand for grabs, you must set the One Grab Transformer property.")] [SerializeField, Interface(typeof(ITransformer)), Optional] private UnityEngine.Object _twoGrabTransformer = null; [Tooltip("The target transform of the Grabbable. If unassigned, " + "the transform of this GameObject will be used.")] [SerializeField] [Optional(OptionalAttribute.Flag.AutoGenerated)] private Transform _targetTransform; /// <summary> /// The maximum number of grab points. Can be either -1 (unlimited), 1, or 2. /// </summary> [Tooltip("The maximum number of grab points. Can be either -1 (unlimited), 1, or 2.")] [SerializeField] private int _maxGrabPoints = -1; public int MaxGrabPoints { get { return _maxGrabPoints; } set { _maxGrabPoints = value; } } public Transform Transform => _targetTransform; public List<Pose> GrabPoints => _selectingPoints; private ITransformer _activeTransformer = null; private ITransformer OneGrabTransformer; private ITransformer TwoGrabTransformer; protected override void Awake() { base.Awake(); OneGrabTransformer = _oneGrabTransformer as ITransformer; TwoGrabTransformer = _twoGrabTransformer as ITransformer; } protected override void Start() { this.BeginStart(ref _started, () => base.Start()); if (_targetTransform == null) { _targetTransform = transform; } if (_oneGrabTransformer != null) { this.AssertField(OneGrabTransformer, nameof(OneGrabTransformer)); OneGrabTransformer.Initialize(this); } if (_twoGrabTransformer != null) { this.AssertField(TwoGrabTransformer, nameof(TwoGrabTransformer)); TwoGrabTransformer.Initialize(this); } // Create a default if no transformers assigned if (OneGrabTransformer == null && TwoGrabTransformer == null) { OneGrabFreeTransformer defaultTransformer = gameObject.AddComponent<OneGrabFreeTransformer>(); _oneGrabTransformer = defaultTransformer; OneGrabTransformer = defaultTransformer; OneGrabTransformer.Initialize(this); } this.EndStart(ref _started); } public override void ProcessPointerEvent(PointerEvent evt) { switch (evt.Type) { case PointerEventType.Select: EndTransform(); break; case PointerEventType.Unselect: ForceMove(evt); EndTransform(); break; case PointerEventType.Cancel: EndTransform(); break; } base.ProcessPointerEvent(evt); switch (evt.Type) { case PointerEventType.Select: BeginTransform(); break; case PointerEventType.Unselect: BeginTransform(); break; case PointerEventType.Move: UpdateTransform(); break; } } private void ForceMove(PointerEvent releaseEvent) { PointerEvent moveEvent = new PointerEvent(releaseEvent.Identifier, PointerEventType.Move, releaseEvent.Pose, releaseEvent.Data); ProcessPointerEvent(moveEvent); } // Whenever we change the number of grab points, we save the // current transform data private void BeginTransform() { // End the transform on any existing transformer before we // begin the new one EndTransform(); int useGrabPoints = _selectingPoints.Count; if (_maxGrabPoints != -1) { useGrabPoints = Mathf.Min(useGrabPoints, _maxGrabPoints); } switch (useGrabPoints) { case 1: _activeTransformer = OneGrabTransformer; break; case 2: _activeTransformer = TwoGrabTransformer; break; default: _activeTransformer = null; break; } if (_activeTransformer == null) { return; } _activeTransformer.BeginTransform(); } private void UpdateTransform() { if (_activeTransformer == null) { return; } _activeTransformer.UpdateTransform(); } private void EndTransform() { if (_activeTransformer == null) { return; } _activeTransformer.EndTransform(); _activeTransformer = null; } protected override void OnDisable() { if (_started) { EndTransform(); } base.OnDisable(); } #region Inject public void InjectOptionalOneGrabTransformer(ITransformer transformer) { _oneGrabTransformer = transformer as UnityEngine.Object; OneGrabTransformer = transformer; } public void InjectOptionalTwoGrabTransformer(ITransformer transformer) { _twoGrabTransformer = transformer as UnityEngine.Object; TwoGrabTransformer = transformer; } public void InjectOptionalTargetTransform(Transform targetTransform) { _targetTransform = targetTransform; } #endregion } }884Views0likes1CommentDoes anyone know how to dynamically constrain hand position during grab interaction?
I am using Quest 2 controllers represented as hands. Started with the Complex Grab sample scene. I've created a custom object with custom grab points, hand pose, etc. and that works fine. What I have been trying to do is, if you have picked up an object the object + hand should collide and not be able to pass through a panel. Think of, for example, drawing on a board. You don't want the pen and hand to simply pass through the board. I know ways to do this in normal Unity or using XRI Toolkit - it's a fairly trivial thing - but the Interaction SDK is not playing nice. I also tried deconstructing the pin board prefab and using those OneHandTranslateTransformer and InteractableTransformerConnection components but I couldn't get it to work how I want. For one, they affect rotation as well as position but I just want to constrain position. In addition, those constraints kick in the moment you grab the object, but I need the constraint behavior to happen only when the tool (e.g., a pen) touches a specific object (e.g., drawing board). Couldn't seem to override this via script. Has anyone done this before with GrabInteractable type of objects? Or more generally, is there a GameObject one can interact with for constraining hand position? Thank you!3.5KViews0likes3CommentsHand Grab Interactable grab Event?
hey I am having trouble finding out which event I need to catch from the HandgGrabInteractable to then from that event call a function. In my case the Photon.RequestOwnership(), on the grabbed object. Here is what I have until now, with help from ChatGPT, and my own research as to what exists and what it just made up and trying to adjust it acordingly: What it should do is, using the PhotonView component and the Hand Grab Interactable, catch the grab event and then get the target of that grab event (being the object being grabbed) to then find the Objects PhotonView component and then call the RequestOwnership() method on it. Alternative Solutions to come to the same result or advice for it is also welcome.2KViews1like0CommentsDistanceGrab Example, the object does not stay still in my hand when I move during the grab
Hi everyone, I have a problem with object grab, I'm using Unity 2022 and Oculus integration 0.46 I take the official oculus example : DistanceGrab Problem: when I grab an object and move, the object doesn't stay still in my hand but moves to the opposite side, I attach the video so it's clearer. Is there a solution to this? Thanks for support.2.7KViews0likes4CommentsOculus Interaction - Grabbing an object starts to jitter and fly away
With the latest update to Oculus Interaction I am not able to grab objects anymore as the methods I used were deprecated. Currently, I have as follows: Hand and Controller Interactors are set up for both left and right. Refer to the attached screenshot. The interactable object having a rigidbody with gravity but no kinematic, box collider, grabbable, hand grab interactable and grab interactable. Issue: (URL to video of issue: https://we.tl/t-XnPdBoyvxe ) When I grab the object it starts to jitter and moves away from my hand but as long as I have my hand pinched or the trigger pressed with the controller I am slightly able to control its movements while it keeps sort of bouncing away from me. If I have kinematic on, the same happens, I am able to change its movements as it flies away from me. Can anyone help please? Part 22KViews1like0Comments