1

I have interactable/throwable VR objects in my game. The thing is that when I hold this object in hand and move him in area of other object trigger I want to force detach this object from hand.

    public void DetachFromHand() //Added method in Interactable.cs
    {
        OnDetachedFromHand(attachedToHand);
    }

    private void OnTriggerEnter(Collider other)
    {
       other.gameObject.GetComponent<Valve.VR.InteractionSystem.Interactable>().DetachFromHand();
    }           

GetComponent<Valve.VR.InteractionSystem.Interactable>() returns null even though object I hold has Interactable script added. What's more I think this isn't the best way to solve this problem.

Morse
  • 8,258
  • 7
  • 39
  • 64
Ardoos
  • 88
  • 7

1 Answers1

1

You should try detaching the object by using hand.DetachObject(gameObject);

Nick
  • 138,499
  • 22
  • 57
  • 95
eggplant
  • 91
  • 11