cancel
Showing results for 
Search instead for 
Did you mean: 

Check if an object is grabbed

jaumet2000
Level 2

 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. jaumet2000_0-1650899356521.png

I'm using Oculus sdk Integration in Unity 2020.3.10.

Any help is appreciated. Thank you

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

WolffRuoff
Level 3

There might be an easier solution but when I did this, I also wanted a few other features so I created my own ITransformer and put it in the Grabbable Script. Once you do this, you can just copy-paste the code in the default ITransformer you want. In an ITransformer, there is a method called BeginTransform() that is called when an object is first grabbed and EndTransform() when it is unselected. I'd recommend saving a bool somewhere else that is changed by these methods.

 

EDIT: If you want to get the gameobject inside the iTransformer script use this (assuming the script is on the gameobject): 

_grabbable.Transform.gameObject

 

View solution in original post

3 REPLIES 3

Exius
Level 2

Hey, did you find a solution? I'm trying to understand the same thing..

WolffRuoff
Level 3

There might be an easier solution but when I did this, I also wanted a few other features so I created my own ITransformer and put it in the Grabbable Script. Once you do this, you can just copy-paste the code in the default ITransformer you want. In an ITransformer, there is a method called BeginTransform() that is called when an object is first grabbed and EndTransform() when it is unselected. I'd recommend saving a bool somewhere else that is changed by these methods.

 

EDIT: If you want to get the gameobject inside the iTransformer script use this (assuming the script is on the gameobject): 

_grabbable.Transform.gameObject

 

hasenav
Level 2

Hi! Yo can check the state in HandGrabInteractor:

private HandGrabInteractor handGrab;
....
if (InteractorState.Select == handGrab.State) -- then a object is grabbed