This is a very simple question, but I couldn’t find an answer anywhere in the documentation.
I’m using the primaryButton to eject a magazine from a gun object that you can pick up, but the gun script doesn’t have information on which hand is grabbing it, so it can know which primaryButton to listen for.
How can I get the hand that is currently grabbing the GO?
1 Like
I finally found the answer, turns out you can’t get what hand is holding the GO, but you can get whether the hand is holding a GO with a certain tag, through each hands’ XRDirectInteractor.
Here’s my code:
public XRDirectInteractor rHand;
public XRDirectInteractor lHand;
public InputManager input;
[HideInInspector]
public bool ejectButton;
void Update()
{
//testing for the selectTarget of each hand, which is what they are holding
if (rHand.selectTarget.tag == "Gun")
ejectButton = input.aButton;
else if (lHand.selectTarget.tag == "Gun")
ejectButton = input.xButton;
else
ejectButton = false;
}
6 Likes