Search Unity

Feedback What’s your preferred architecture for managing hands and especially handedness?

Discussion in 'XR Interaction Toolkit and Input' started by FarmerInATechStack, Feb 3, 2021.

  1. FarmerInATechStack

    FarmerInATechStack

    Joined:
    Dec 28, 2020
    Posts:
    57
    I’m building out a prototype currently for Oculus Quest 2 and wanted to ask for feedback here: how do you prefer to implement a “dominant hand” and the capability to switch handedness? Are there existing code samples or design patterns to learn from?

    The above question was inspired by the following:
    • I was thinking of the best code architecture for my prototype.
    • I realized that I actually don’t need a notion of handedness for my prototype.
    • Given the above, I can use the same scripting logic for each hand but I was curious about the architectural considerations of different approaches.
    • I’d love to learn about how others have approached handedness or if there are existing solutions you’d recommend I check out.
    Some concepts that come to mind:
    • Concept #1: I could have separate scripts (“DominantHand” and “NonDominantHand”), put those both on each hand, but toggle them on/off based on player preference.
    • Concept #2: I could just have one “HandInteractions” script attached to each hand and encapsulate all hand behavior into that. I’d then toggle each hand’s behavior (dominant or not) with some larger “HandManager” script.
    • Concept #3: it might be better to totally decouple these from the hand objects and go with a “manager” pattern. I could write one general “HandManager” that looks for a right/left hand; assigns and controls hand dominance; and encapsulates all logic.
    Concept #1 feels too fragmented, too dependent on inspector configuration, and terrible overall.

    Concept #2 feels good but still too fragmented.

    Concept #3 feels like it encapsulates a good amount of logical depth into one place and is currently my favorite approach.

    I’d value learning from any feedback or related samples - cheers!