コード例 #1
0
    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
    }
コード例 #2
0
    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;
    }
コード例 #3
0
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;
        isHeld = true;

        return new LeapHandleState(this);
    }
コード例 #4
0
    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));
    }
コード例 #6
0
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;

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

        return new LeapDrivingLeverState(this);
    }
コード例 #7
0
    public override LeapState Activate(HandTypeBase h)
    {
        if (owner != null)
            return null;

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

        swingableObj.isHeld = true;
        handController.HideHand();
    }
コード例 #9
0
    public override LeapState Activate(HandTypeBase h)
    {
        owner = h;

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

        return(new LeapDrivingLeverState(this));
    }
コード例 #10
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);
    }
コード例 #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;
    }
コード例 #16
0
    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);
    }
コード例 #18
0
 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));
    }
コード例 #20
0
    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;
    }
コード例 #21
0
 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));
    }
コード例 #25
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;
    }
コード例 #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));
    }
コード例 #30
0
    public override LeapState Release(HandTypeBase h)
    {
        isHeld = false;

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

        if (canAccelerate)
        {
            UpdateBrakes();
        }

        return base.Release(h);
    }
コード例 #31
0
    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;
    }
コード例 #32
0
    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");
 }
コード例 #34
0
    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;
            }
        }
    }
コード例 #38
0
 public override LeapState Activate(HandTypeBase h)
 {
     return null;
 }
コード例 #39
0
    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;
 }
コード例 #42
0
 public override void UpdateTransform(HandTypeBase t)
 {
     UpdateShootable(t);
 }
コード例 #43
0
 public override LeapState Release(HandTypeBase h)
 {
     GameObject.Destroy(handOnLever);
     isHeld = false;
     return base.Release(h);
 }
コード例 #44
0
 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));
 }
コード例 #51
0
 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);
 }
コード例 #53
0
 public override void UpdateTransform(HandTypeBase t)
 {
     RotateLever();
     handOnLever.transform.position = grabCenterOffset.position;
     handOnLever.transform.position += new Vector3(0, 0.1f, -0.2f);
 }
コード例 #54
0
 public override LeapState Release(HandTypeBase h)
 {
     isHeld = false;
     return base.Release(h);
 }
コード例 #55
0
 public override LeapState Activate(HandTypeBase h)
 {
     spotLight.enabled = true;
     bulbLight.enabled = true;
     return base.Activate(h);
 }
コード例 #56
0
    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
ファイル: UnityHand.cs プロジェクト: jmenzel/3D-Mondrimat
    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();
    }
コード例 #59
0
    public override void UpdateTransform(HandTypeBase t)
    {
        base.UpdateTransform(t);

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