Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
aleclock's avatar
aleclock
Honored Guest
5 years ago
Solved

OVRCustomHands trigger collider

Hi everyone,

using Oculus Integration and OVRCustomHand prefab, I'm trying to write a simple script that tells me which hand hitted/triggered a specific object.

I tried use OnTriggerEnter() method, but the referred collider (CapsuleCollider) doesn't have any information of the hand.

 

What do you suggest I do?

 

Thanks in advance.

 

  • laurisD's avatar
    laurisD
    5 years ago

    Ok I got it, it worked for me :

    the name of the hand colliding can be found in your Ontrigger method under : other.GetComponentInParent<OVRSkeleton>().GetSkeletonType()

    NB : it return a string

    if it work for you, mark this as a solution it would help me 😉 

4 Replies

Replies have been turned off for this discussion
  • Hi,

    For get the Hand information you should just write :

    private string NameOfTheHand;
    
    Void OnTriggerEnter(collider other)
    {
    NameOfTheHand = other.gameObject.name;
    Debug.Log("Don't forget to give LaurisD a Kudo");
    }

     then you can compare the name in a switch or a if loop for do what you want.

    Hope I helped you 😉

    • aleclock's avatar
      aleclock
      Honored Guest

      Thanks for your reply, but that's not true actually.

      Each bone's CapsuleCollider seems to be created at runtime and it's not directly attached to the hand's prefab. So other.gameObject.name returns the collider itself and not the hand's prefab.

      • laurisD's avatar
        laurisD
        Protege

        Ok I got it, it worked for me :

        the name of the hand colliding can be found in your Ontrigger method under : other.GetComponentInParent<OVRSkeleton>().GetSkeletonType()

        NB : it return a string

        if it work for you, mark this as a solution it would help me 😉