void UpdateShootable(HandTypeBase t)
    {
        Collider o = GetComponent<Collider>();

        Vector3 handOffset = new Vector3();
        Vector3 grabOffsetPos = new Vector3();
        bool fingerFound = false;

        // Uses Index Finger to aim
        if (owner.unityHand.unityFingers.ContainsKey(FINGERS.INDEX))
        {
            fingerFound = true;
        }

        o.transform.position = owner.transform.position + handOffset - grabOffsetPos;

        Vector3 tipPosition;

        if (fingerFound)
        {
            tipPosition = owner.unityHand.unityFingers[FINGERS.INDEX].transform.position;
        }
        else
        {
            tipPosition = owner.unityHand.hand.Fingers.Frontmost.TipPosition.ToUnityTranslated();
        }

        //Look at Finger
        o.transform.LookAt(tipPosition, owner.unityHand.transform.up); // Add finger rotation
    }
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

        Vector3 dir = transform.position - prevPos;
        dir = dir.normalized;
        dir = dir * (Vector3.Distance(transform.position, prevPos) * owner.unityHand.settings.throwingStrength);

        VelocityCheck(dir);

        if (!rigidbody.isKinematic)
        {
            rigidbody.velocity = Vector3.zero;
            rigidbody.angularVelocity = Vector3.zero;

            // Necessary to switch Hand Updates for collisions
            if (collisionOccurred)
            {
                owner.unityHand.runUpdate = false;
            }
            else
            {
                owner.unityHand.runUpdate = true;
            }
        }

        prevPos = transform.position;
        velTime += Time.deltaTime;
    }
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;
        isHeld = true;

        return new LeapHandleState(this);
    }
    public override void Enter(HandTypeBase o)
    {
        handController = o;
        if (activeObj)
            handController.SetActiveObject(activeObj);

        handController.HideHand();
    }
示例#5
0
    /// <summary>
    /// Method is triggered by "Grab" or similar method from current state of HandType
    /// </summary>
    /// <returns>new Leapstate or null to remain in current state</returns>
    public virtual LeapState Activate(HandTypeBase h)
    {
        if (!owner)
        {
            owner = h;
        }

        return(new LeapGodHandState(this));
    }
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;

        handOnLever = (GameObject)GameObject.Instantiate(hand, grabCenterOffset.position, Quaternion.identity);
        isHeld = true;

        return new LeapDrivingLeverState(this);
    }
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
            return null;

        GetComponent<Rigidbody>().isKinematic = true;
        GetComponent<Rigidbody>().useGravity = false;
        return new LeapShootableState(this);
    }
    public override void Enter(HandTypeBase o)
    {
        handController = o;
        if (activeObj)
            handController.SetActiveObject(activeObj);

        swingableObj.isHeld = true;
        handController.HideHand();
    }
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;

        handOnLever = (GameObject)GameObject.Instantiate(hand, grabCenterOffset.position, Quaternion.identity);
        isHeld      = true;

        return(new LeapDrivingLeverState(this));
    }
    /// <summary>
    /// Method is triggered by "Grab" or similar method from current state of HandType
    /// </summary>
    /// <returns>new Leapstate or null to remain in current state</returns>
    public virtual LeapState Activate(HandTypeBase h)
    {
        if (!owner)
        {
            owner = h;
        }

        return new LeapGodHandState(this);
    }
示例#11
0
    public override void Enter(HandTypeBase o)
    {
        handController = o;
        if (activeObj)
        {
            handController.SetActiveObject(activeObj);
        }

        handController.HideHand();
    }
    public override void Enter(HandTypeBase o)
    {
        handController = o;
        if (activeObj)
        {
            handController.SetActiveObject(activeObj);
        }

        swingableObj.isHeld = true;
        handController.HideHand();
    }
示例#13
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
        {
            return(null);
        }

        rigidbody.isKinematic = true;
        rigidbody.useGravity  = false;
        return(new LeapShootableState(this));
    }
示例#14
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
            return null;

        rigidbody.isKinematic = true;
        rigidbody.useGravity = false;
        collider.enabled = false;

        return new LeapSwingableState(this);
    }
    private void OnTriggerExit(Collider c)
    {
        HandTypeBase h = c.GetComponent <HandTypeBase>();

        if (h && !resetPeriod)
        {
            resetting = true;
        }

        newContact = true;
    }
    public override void Enter(HandTypeBase o)
    {
        handController = o;
        if (activeObj)
        {
            handController.SetActiveObject(activeObj);

            if (!activeObj.handIsVisible)
                handController.HideHand();
        }
    }
示例#17
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
            return null;

        if (canGoThroughGeometry && rigidbody)
        {
            rigidbody.isKinematic = true;
            rigidbody.useGravity = false;
        }
        return base.Activate(h);
    }
 public override void UpdateTransform(HandTypeBase t)
 {
     if (!owner)
     {
         t.SetActiveObject(this);
         owner = t;
     }
     else
     {
         RotateSteeringWheel();
         isHeld = true;
     }
 }
示例#19
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
        {
            return(null);
        }

        GetComponent <Rigidbody>().isKinematic = true;
        GetComponent <Rigidbody>().useGravity  = false;
        GetComponent <Collider>().enabled      = false;

        return(new LeapSwingableState(this));
    }
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            GetComponent<Rigidbody>().isKinematic = false;
            GetComponent<Rigidbody>().useGravity = true;
            state = base.Release(h);
        }

        return state;
    }
 public override void UpdateTransform(HandTypeBase t)
 {
     if (!owner)
     {
         t.SetActiveObject(this);
         owner = t;
     }
     else
     {
         RotateSteeringWheel();
         isHeld = true;
     }
 }
示例#22
0
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            rigidbody.isKinematic = false;
            rigidbody.useGravity  = true;
            state = base.Release(h);
        }

        return(state);
    }
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
        {
            return(null);
        }

        if (canGoThroughGeometry && rigidbody)
        {
            rigidbody.isKinematic = true;
            rigidbody.useGravity  = false;
        }
        return(base.Activate(h));
    }
示例#24
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
        {
            return(null);
        }

        if (canGoThroughGeometry && GetComponent <Rigidbody>())
        {
            GetComponent <Rigidbody>().isKinematic = true;
            GetComponent <Rigidbody>().useGravity  = false;
        }
        return(base.Activate(h));
    }
    public virtual LeapState Release(HandTypeBase h)
    {
        if (!isStatePersistent)
        {
            if (h && h.activeObj)
                h.activeObj = null;
            else
                owner.activeObj = null;

            owner = null;
            return new LeapGodHandState(); // each object should return a state
        }
        return null;
    }
示例#26
0
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            GetComponent <Rigidbody>().isKinematic = false;
            GetComponent <Rigidbody>().useGravity  = true;
            GetComponent <Collider>().enabled      = true;

            state = base.Release(h);
        }

        return(state);
    }
示例#27
0
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            rigidbody.isKinematic = false;
            rigidbody.useGravity = true;
            collider.enabled = true;

            state = base.Release(h);
        }

        return state;
    }
示例#28
0
    public virtual void UpdateTransform(HandTypeBase t)
    {
        Vector3    grabOffsetPos = new Vector3();
        Quaternion grabOffsetRot = Quaternion.identity;

        if (grabCenterOffset)
        {
            grabOffsetPos = grabCenterOffset.transform.position - transform.position;
            grabOffsetRot = grabCenterOffset.localRotation;
        }

        transform.position  = t.transform.position - grabOffsetPos;
        transform.rotation  = t.transform.rotation;
        transform.rotation *= grabOffsetRot;
    }
示例#29
0
    /// <summary>
    /// Method is triggered by "Grab" or similar method from current state of HandType
    /// </summary>
    /// <returns>new Leapstate or null to remain in current state</returns>
    public virtual LeapState Activate(HandTypeBase h)
    {
        if (!owner)
        {
            owner = h;
        }

        if (this.tag == "Tool")
        {
            this.GetComponent <CapsuleCollider>().enabled = false;
            this.GetComponent <BoxCollider>().enabled     = true;
        }

        return(new LeapGodHandState(this));
    }
    public override LeapState Release(HandTypeBase h)
    {
        isHeld = false;

        if (handOnHandle)
        {
            GameObject.Destroy(handOnHandle);
        }

        if (canAccelerate)
        {
            UpdateBrakes();
        }

        return base.Release(h);
    }
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            if (canGoThroughGeometry)
            {
                rigidbody.isKinematic = false;
                rigidbody.useGravity = true;
            }
            ThrowHeldObject();
            state = base.Release(h);
        }
        return state;
    }
    public override LeapState Release(HandTypeBase h)
    {
        LeapState state = null;

        if (!isStatePersistent)
        {
            if (canGoThroughGeometry)
            {
                GetComponent <Rigidbody>().isKinematic = false;
                GetComponent <Rigidbody>().useGravity  = true;
            }
            ThrowHeldObject();
            state = base.Release(h);
        }
        return(state);
    }
示例#33
0
 void Start()
 {
     handType = (HandTypeBase)Instantiate(handType, transform.position, Quaternion.identity);
     handType.SetOwner(this);
     handType.name    = isRightHand ? "rightHand" : "leftHand";
     renderer.enabled = false;         // Disable visual indicator for Unityhand
     if (initialLeapObject)
     {
         initialLeapObject.gameObject.SetActive(true);
         handType.ChangeState(initialLeapObject.Activate(handType));
     }
     originalPos     = transform.localPosition;
     detectedFingers = new FingerDetection(this);
     InstantiateFingers();
     Contro = GameObject.Find("Controller");
 }
    public override LeapState Release(HandTypeBase h)
    {
        isHeld = false;

        if (handOnHandle)
        {
            GameObject.Destroy(handOnHandle);
        }

        if (canAccelerate)
        {
            UpdateBrakes();
        }

        return(base.Release(h));
    }
示例#35
0
    public virtual LeapState Release(HandTypeBase h)
    {
        if (!isStatePersistent)
        {
            if (h && h.activeObj)
            {
                h.activeObj = null;
            }
            else
            {
                owner.activeObj = null;
            }

            owner = null;
            return(new LeapGodHandState()); // each object should return a state
        }
        return(null);
    }
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

        if (!rigidbody.isKinematic)
        {
            rigidbody.velocity        = Vector3.zero;
            rigidbody.angularVelocity = Vector3.zero;

            // Necessary to switch Hand Updates for collisions
            if (collisionOccurred)
            {
                owner.unityHand.runUpdate = false;
            }
            else
            {
                owner.unityHand.runUpdate = true;
            }
        }
    }
示例#37
0
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

        if (!rigidbody.isKinematic)
        {
            rigidbody.velocity = Vector3.zero;
            rigidbody.angularVelocity = Vector3.zero;

            // Necessary to switch Hand Updates for collisions
            if (collisionOccurred)
            {
                owner.unityHand.runUpdate = false;
            }
            else
            {
                owner.unityHand.runUpdate = true;
            }
        }
    }
 public override LeapState Activate(HandTypeBase h)
 {
     return null;
 }
    public override void UpdateTransform(HandTypeBase t)
    {
        UpdateLocalPositions();

        GrabbingUpdate();
    }
示例#40
0
 public override void Enter(HandTypeBase o)
 {
     handController = o;
     handController.HideHand();
 }
示例#41
0
 public override void UpdateTransform(HandTypeBase t)
 {
     RotateRod();
     handOnGrip.transform.position = grabCenterOffset.position;
 }
 public override void UpdateTransform(HandTypeBase t)
 {
     UpdateShootable(t);
 }
 public override LeapState Release(HandTypeBase h)
 {
     GameObject.Destroy(handOnLever);
     isHeld = false;
     return base.Release(h);
 }
 public override void Enter(HandTypeBase o)
 {
     handController = o;
     handController.HideHand();
 }
 public override LeapState Activate(HandTypeBase h)
 {
     return(null);
 }
示例#46
0
 public override void UpdateTransform(HandTypeBase t)
 {
     RotateLever();
     handOnLever.transform.position  = grabCenterOffset.position;
     handOnLever.transform.position += new Vector3(0, 0.1f, -0.2f);
 }
示例#47
0
 public override LeapState Release(HandTypeBase h)
 {
     GameObject.Destroy(handOnGrip);
     isHeld = false;
     return(base.Release(h));
 }
示例#48
0
 public override LeapState Activate(HandTypeBase h)
 {
     isTriggered = true;
     return base.Activate(h);
 }
示例#49
0
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

        UpdatePunchingVelocity();
    }
示例#50
0
 public override LeapState Release(HandTypeBase h)
 {
     spotLight.enabled = false;
     bulbLight.enabled = false;
     return(base.Release(h));
 }
 public override LeapState Release(HandTypeBase h)
 {
     spotLight.enabled = false;
     bulbLight.enabled = false;
     return base.Release(h);
 }
示例#52
0
 public override void UpdateTransform(HandTypeBase t)
 {
     UpdateShootable(t);
 }
 public override void UpdateTransform(HandTypeBase t)
 {
     RotateLever();
     handOnLever.transform.position = grabCenterOffset.position;
     handOnLever.transform.position += new Vector3(0, 0.1f, -0.2f);
 }
 public override LeapState Release(HandTypeBase h)
 {
     isHeld = false;
     return base.Release(h);
 }
 public override LeapState Activate(HandTypeBase h)
 {
     spotLight.enabled = true;
     bulbLight.enabled = true;
     return base.Activate(h);
 }
    public override void UpdateTransform(HandTypeBase t)
    {
        UpdateLocalPositions();

        GrabbingUpdate();
    }
示例#57
0
 public override LeapState Activate(HandTypeBase h)
 {
     spotLight.enabled = true;
     bulbLight.enabled = true;
     return(base.Activate(h));
 }
示例#58
0
    void Start()
    {
        handType = (HandTypeBase)Instantiate(handType, transform.position, Quaternion.identity);
        handType.SetOwner(this);
        handType.name = isRightHand ? "rightHand" : "leftHand";

        renderer.enabled = false; // Disable visual indicator for Unityhand

        if (initialLeapObject)
        {
            initialLeapObject.gameObject.SetActive(true);
            handType.ChangeState(initialLeapObject.Activate(handType));
        }

        originalPos = transform.localPosition;

        detectedFingers = new FingerDetection(this);
        InstantiateFingers();
    }
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

        UpdatePunchingVelocity();
    }
示例#60
0
 public override LeapState Activate(HandTypeBase h)
 {
     isTriggered = true;
     return(base.Activate(h));
 }