Beispiel #1
0
 private void AddTrail(IHand hand)
 {
     if (useTrail && (hand.Centre() - lastTrailPosition).magnitude > 0.01f)
     {
         lastTrailPosition = hand.Centre();
         trail.Add(GameObject.Instantiate(trailObject, lastTrailPosition, Quaternion.identity));
     }
 }
Beispiel #2
0
    public Knob FindClosestTo(IHand hand)
    {
        Vector3 distance = new Vector3(1, 0.0f, 0.0f);

        Knob closest = null;

        knobs.ForEach(knob => {
            Vector3 new_distance = hand.Centre() - knob.Position();
            if (new_distance.magnitude < distance.magnitude)
            {
                closest  = knob;
                distance = new_distance;
            }
        });
        return(closest);
    }
Beispiel #3
0
    public void OnHandUpdate(IHand hand)
    {
        if (!hand.IsPresent())
        {
            HandNotNearKnob();
            return;
        }

        AddTrail(hand);

        var closest = knobs.FindClosestTo(hand.Centre());

        if (closest == null)
        {
            HandNotNearKnob();
            return;
        }

        HandNearKnob(closest);
    }
Beispiel #4
0
    public string OnHandUpdate(IHand hand)
    {
        if (!hand.IsPresent())
        {
            ReleaseAllKnobs();
            return(text);
        }
        debug.Log("hand position: " + hand.Centre());

        debug.Log("text: " + text);
        var closest = knobs.FindClosestTo(hand);

        // debug.Log("Closest: " + closest);
        if (closest == null)
        {
            HandleAwayFromKnobs();
            // debug.Log("Nearly grabbed things: " + string.Join(", ", close_things.ToList().Select(t => t.name).ToArray()));
            return(text);
        }

        HandleCloseToKnob(hand, closest);
        return(text);
    }