示例#1
0
        //Change this to VR
        private void HandHoverUpdate(Hand hand)
        {
            if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
            {
                if (hand.currentAttachedObject == Leversobj_1)
                {
                    // Save our position/rotation so that we can restore it when we detach
                    oldPosition = Levers_1.position;
                    oldRotation = Levers_1.rotation;

                    // Call this to continue receiving HandHoverUpdate messages,
                    // and prevent the hand from hovering over anything else
                    hand.HoverLock(leverinter_1);

                    // Attach this object to the hand
                    hand.AttachObject(Leversobj_1, attachmentFlags);
                    Levers_1.Rotate(Vector3.right, -3f);
                }
                if (hand.currentAttachedObject == Leversobj_2)
                {
                    // Save our position/rotation so that we can restore it when we detach
                    oldPosition = Levers_2.position;
                    oldRotation = Levers_2.rotation;

                    // Call this to continue receiving HandHoverUpdate messages,
                    // and prevent the hand from hovering over anything else
                    hand.HoverLock(leverinter_2);

                    // Attach this object to the hand
                    hand.AttachObject(Leversobj_2, attachmentFlags);
                    Levers_2.Rotate(Vector3.right, -3f);
                }
            }
        }
示例#2
0
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            //Transform off;



            if (hand.currentAttachedObject == null && startingGrabType != GrabTypes.None)
            {
                if (hand.otherHand.currentAttachedObject == null ||
                    hand.otherHand.currentAttachedObject.name.Substring(0, 3) != "Bow")
                {
                    GameObject newBow = Instantiate(bow);
                    GameObject hold   = newBow.transform.Find("Bow").Find("Hold Point").gameObject;
                    hand.AttachObject(newBow, startingGrabType, Hand.defaultAttachmentFlags, hold.transform);
                }
                else
                {
                    GameObject newArrow = Instantiate(arrow);
                    //off.position = newArrow.transform.position - new Vector3(0, 0, 0);
                    //Vector3 off = new Vector3(newArrow.transform.position.x, newArrow.transform.position.y, newArrow.transform.position.z - 5);
                    //arrow.transform.position = off;
                    GameObject tail = newArrow.transform.Find("Tail").gameObject;
                    // Attach this object to the hand
                    hand.AttachObject(newArrow, startingGrabType, Hand.defaultAttachmentFlags, tail.transform);
                }
            }
        }
        //-------------------------------------------------
        // Called every Update() while a Hand is hovering over this object
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            if (hand.GuessCurrentHandType() == Hand.HandType.Right)
            {
                //  Trigger gets pulled
                if (hand.GetStandardInteractionButtonDown())
                {
                    //  Hand is not already holding this object
                    if (hand.currentAttachedObject != gameObject)
                    {
                        //  Hand is hovering over toolbox item
                        if (isFake)
                        {
                            //  Spawn a new item and attach it
                            GameObject newPiece = Instantiate(gMan.tools[pieceIndex]) as GameObject;
                            //newPiece.transform.localScale *= growthMod;
                            newPiece.transform.position = hand.transform.position;
                            newPiece.transform.rotation = hand.transform.rotation;
                            newPiece.GetComponent <Movable>().isFake = false;

                            // Call this to continue receiving HandHoverUpdate messages,
                            // and prevent the hand from hovering over anything else
                            hand.HoverLock(newPiece.GetComponent <Interactable>());

                            // Attach this object to the hand
                            hand.AttachObject(newPiece, newPiece.GetComponent <Movable>().attachmentFlags);
                        }
                        else
                        {
                            // Call this to continue receiving HandHoverUpdate messages,
                            // and prevent the hand from hovering over anything else
                            hand.HoverLock(GetComponent <Interactable>());

                            //  Unsnap in case
                            if (this.GetComponent <SnappingScript>())
                            {
                                GetComponent <SnappingScript>().Unsnap();
                            }

                            //this.GetComponentInChildren<MeshCollider>().convex = false;

                            //  if it's the ball enable physics
                            if (this.GetComponentInChildren <Ball>())
                            {
                                this.GetComponentInChildren <Rigidbody>().isKinematic = true;
                            }

                            // Attach this object to the hand
                            hand.AttachObject(gameObject, attachmentFlags);
                        }
                    }
                }
            }
        }
        // Called every Update() while a Hand is hovering over this object
        private void HandHoverUpdate(Hand hand)
        {
            Hand.AttachmentFlags attachmentFlags = Hand.defaultAttachmentFlags;
            if ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))
            {
                if (hand.currentAttachedObject != gameObject)
                {
                    // Call this to continue receiving HandHoverUpdate messages, and prevent the hand from hovering over anything else
                    hand.HoverLock(GetComponent <Interactable>());

                    // Attach this object to the hand
                    hand.AttachObject(gameObject, attachmentFlags);

                    hand.transform.Find("ControllerHoverHighlight").gameObject.SetActive(false);
                    hand.transform.Find("ControllerButtonHints").gameObject.SetActive(false);
                }
                else
                {
                    activeHand = null;
                    // Detach this object from the hand
                    hand.DetachObject(gameObject);

                    // Call this to undo HoverLock
                    hand.HoverUnlock(GetComponent <Interactable>());

                    hand.transform.Find("ControllerHoverHighlight").gameObject.SetActive(true);
                    hand.transform.Find("ControllerButtonHints").gameObject.SetActive(true);
                }
            }
        }
示例#5
0
        private void HandHoverUpdate(Hand hand)
        {
            if (canPickUp)
            {
                if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
                {
                    //Stuff
                    if (hand.currentAttachedObject != gameObject)
                    {
                        oldPosition = transform.position;
                        oldRotation = transform.rotation;
                        //Keeps hover update function going
                        hand.HoverLock(GetComponent <Interactable> ());

                        hand.AttachObject(gameObject, attatchmentFlags);
                    }
                    else
                    {
                        hand.DetachObject(gameObject);

                        hand.HoverUnlock(GetComponent <Interactable> ());

                        //Would be replaced with activating RigidBody
                        transform.position = oldPosition;
                        transform.rotation = oldRotation;
                    }
                }
            }
        }
示例#6
0
    //-------------------------------------------------
    // Called every Update() while a Hand is hovering over this object
    //-------------------------------------------------
    private void HandHoverUpdate(ValveVR.Hand hand)
    {
        ValveVR.GrabTypes startingGrabType = hand.GetGrabStarting();
        bool isGrabEnding = hand.IsGrabEnding(this.gameObject);

        if (interactable.attachedToHand == null && startingGrabType != ValveVR.GrabTypes.None)
        {
            // Save our position/rotation so that we can restore it when we detach
            //oldPosition = transform.position;
            //oldRotation = transform.rotation;

            // Call this to continue receiving HandHoverUpdate messages,
            // and prevent the hand from hovering over anything else
            hand.HoverLock(interactable);

            // Attach this object to the hand
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
        }
        else if (isGrabEnding)
        {
            // Detach this object from the hand
            hand.DetachObject(gameObject);

            // Call this to undo HoverLock
            hand.HoverUnlock(interactable);

            // Restore position/rotation
            //transform.position = oldPosition;
            //transform.rotation = oldRotation;
        }
    }
示例#7
0
 private void HandHoverUpdate(Hand hand)
 {
     if (hand.GetStandardInteractionButtonDown())
     {
         hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
     }
 }
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabEnding(this.gameObject);

            if (startingGrabType != GrabTypes.None)
            {
                hand.HoverLock(interactable);

                initialMappingOffset = linearMapping.value - CalculateLinearMapping(hand.transform);
                sampleCount          = 0;
                mappingChangeRate    = 0.0f;

                hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
            }

            if (isGrabEnding)
            {
                hand.HoverUnlock(interactable);

                hand.DetachObject(gameObject);

                CalculateMappingChangeRate();
            }

            if (hand.currentAttachedObject == interactable.gameObject)
            {
                UpdateLinearMapping(hand.transform);
            }
        }
示例#9
0
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            BookIndex Book             = GetComponentInParent <BookIndex>();

            if (startingGrabType == GrabTypes.Grip)
            {
                if (Book.coverMapping.value < Book.lockThreshold || hand == Player.instance.rightHand)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                    hand.HideGrabHint();
                }
            }
            else if (startingGrabType == GrabTypes.Pinch && hand == Player.instance.leftHand)
            {
                if (hand.LastCollider == Book.lowerBackHandle)
                {
                    hand.LastCollider = Book.backPageHandle.GetComponent <Collider>();
                    if (hand.LastCollider.GetComponent <PageHandle>().IsActive())
                    {
                        hand.LastCollider.GetComponentInParent <PageDrive>().SendMessage("HandHoverUpdate", hand);
                    }
                }
            }
        }
示例#10
0
        //-------------------------------------------------
        protected virtual void OnHandHoverBegin(Hand hand)
        {
            bool showHint = false;

            // "Catch" the throwable by holding down the interaction button instead of pressing it.
            // Only do this if the throwable is moving faster than the prescribed threshold speed,
            // and if it isn't attached to another hand
            if (!attached && catchingSpeedThreshold != -1)
            {
                float catchingThreshold = catchingSpeedThreshold * SteamVR_Utils.GetLossyScale(Player.instance.trackingOriginTransform);

                GrabTypes bestGrabType = hand.GetBestGrabbingType();

                if (bestGrabType != GrabTypes.None)
                {
                    if (rigidbody.velocity.magnitude >= catchingThreshold)
                    {
                        hand.AttachObject(gameObject, bestGrabType, attachmentFlags);
                        showHint = false;
                    }
                }
            }

            if (showHint)
            {
                hand.ShowGrabHint();
            }
        }
示例#11
0
        // Token: 0x06002041 RID: 8257 RVA: 0x0009F4E8 File Offset: 0x0009D6E8
        private void PhysicsAttach(Hand hand)
        {
            this.PhysicsDetach(hand);
            Rigidbody rigidbody = null;
            Vector3   item      = Vector3.zero;
            float     num       = float.MaxValue;

            for (int i = 0; i < this.rigidBodies.Count; i++)
            {
                float num2 = Vector3.Distance(this.rigidBodies[i].worldCenterOfMass, hand.transform.position);
                if (num2 < num)
                {
                    rigidbody = this.rigidBodies[i];
                    num       = num2;
                }
            }
            if (rigidbody == null)
            {
                return;
            }
            if (this.attachMode == ComplexThrowable.AttachMode.FixedJoint)
            {
                Util.FindOrAddComponent <Rigidbody>(hand.gameObject).isKinematic = true;
                hand.gameObject.AddComponent <FixedJoint>().connectedBody        = rigidbody;
            }
            hand.HoverLock(null);
            Vector3 b = hand.transform.position - rigidbody.worldCenterOfMass;

            b    = Mathf.Min(b.magnitude, 1f) * b.normalized;
            item = rigidbody.transform.InverseTransformPoint(rigidbody.worldCenterOfMass + b);
            hand.AttachObject(base.gameObject, this.attachmentFlags, "");
            this.holdingHands.Add(hand);
            this.holdingBodies.Add(rigidbody);
            this.holdingPoints.Add(item);
        }
示例#12
0
        public bool TryAttachTower(TowerObject tower, Vector3 positionOffset, Vector3 rotationOffset, Hand hand)
        {
            TowerObject temp = attachedTower;

            if (temp != null)
            {
                if (allowsSwapping)
                {
                    RemoveTower();
                    hand.AttachObject(temp.gameObject, GrabTypes.Grip, temp.attachmentFlags, temp.attachentOffset);
                    AttachTower(tower, positionOffset, rotationOffset);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                AttachTower(tower, positionOffset, rotationOffset);

                return(true);
            }
        }
示例#13
0
        //-------------------------------------------------
        private void OnHandHoverBegin(Hand hand)
        {
            bool showHint = false;

            // "Catch" the throwable by holding down the interaction button instead of pressing it.
            // Only do this if the throwable is moving faster than the prescribed threshold speed,
            // and if it isn't attached to another hand
            if (!attached)
            {
                if (hand.buttonsListener.GetStandardInteractionButton())
                {
                    Rigidbody rb = GetComponent <Rigidbody>();
                    if (rb.velocity.magnitude >= catchSpeedThreshold)
                    {
                        hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
                        showHint = false;
                    }
                }
            }

            if (showHint)
            {
                ControllerButtonHints.ShowButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            }
        }
        //-------------------------------------------------
        // Called every Update() while a Hand is hovering over this object
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            if (hand.buttonsListener.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
            {
                if (hand.currentAttachedObject != gameObject)
                {
                    // Save our position/rotation so that we can restore it when we detach
                    oldPosition = transform.position;
                    oldRotation = transform.rotation;

                    // Call this to continue receiving HandHoverUpdate messages,
                    // and prevent the hand from hovering over anything else
                    hand.HoverLock(GetComponent <Interactable>());

                    // Attach this object to the hand
                    hand.AttachObject(gameObject, attachmentFlags);
                }
                else
                {
                    // Detach this object from the hand
                    hand.DetachObject(gameObject);

                    // Call this to undo HoverLock
                    hand.HoverUnlock(GetComponent <Interactable>());

                    // Restore position/rotation
                    transform.position = oldPosition;
                    transform.rotation = oldRotation;
                }
            }
        }
示例#15
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                if (hand.handType == SteamVR_Input_Sources.RightHand)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                }
                else
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset2);
                }
                hand.HideGrabHint();
            }
        }
示例#16
0
        //-------------------------------------------------
        private void PhysicsAttach(Hand hand)
        {
            PhysicsDetach(hand);

            Rigidbody holdingBody = null;

            Vector3 holdingPoint = Vector3.zero;

            // The hand should grab onto the nearest rigid body
            float closestDistance = float.MaxValue;

            for (int i = 0; i < rigidBodies.Count; i++)
            {
                float distance = Vector3.Distance(rigidBodies[i].worldCenterOfMass, hand.transform.position);

                if (distance < closestDistance)
                {
                    holdingBody = rigidBodies[i];

                    closestDistance = distance;
                }
            }

            // Couldn't grab onto a body
            if (holdingBody == null)
            {
                return;
            }

            // Create a fixed joint from the hand to the holding body
            //if (attachMode == AttachMode.FixedJoint)
            //{
            //    Rigidbody handRigidbody = Util.FindOrAddComponent<Rigidbody>(hand.gameObject);
            //    handRigidbody.isKinematic = false;

            //    FixedJoint handJoint = Util.FindOrAddComponent<FixedJoint>(hand.gameObject);//hand.gameObject.AddComponent<FixedJoint>();
            //    handJoint.connectedBody = holdingBody;
            //}

            // Don't let the hand interact with other things while it's holding us
            hand.HoverLock(null);

            // Affix this point
            Vector3 offset = hand.transform.position - holdingBody.worldCenterOfMass;

            offset = Mathf.Min(offset.magnitude, 1.0f) * offset.normalized;

            holdingPoint = holdingBody.transform.InverseTransformPoint(holdingBody.worldCenterOfMass + offset);

            hand.AttachObject(this.gameObject, attachmentFlags);

            // Update holding list
            holdingHands.Add(hand);

            holdingBodies.Add(holdingBody);

            holdingPoints.Add(holdingPoint);
        }
示例#17
0
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
            }
        }
示例#18
0
 //-------------------------------------------------
 private void HandHoverUpdate(Hand hand)
 {
     //Trigger got pressed
     if (hand.buttonsListener.GetStandardInteractionButtonDown())
     {
         hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
         ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
     }
 }
示例#19
0
 //-------------------------------------------------
 private void HandHoverUpdate(Hand hand)
 {
     //Trigger got pressed
     if ((ViveInput.GetPressDown(HandRole.LeftHand, ControllerButton.Trigger)))
     {
         hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
         ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
     }
 }
示例#20
0
        IEnumerator StartAttach()
        {
            yield return(new WaitForEndOfFrame());

            Hand hand = FindObjectOfType <Player>().rightHand;

            hand.HoverLock(GetComponent <Interactable>());
            hand.AttachObject(gameObject, attachmentFlags);
            attached = true;
        }
示例#21
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, hand.name == "LeftHand" ? attachmentOffsetLeft : attachmentOffsetRight);
                hand.HideGrabHint();
            }
        }
示例#22
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None && (canPickupWhileSmall || !sizeManager.isPlayerSmall()))
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
            }
        }
示例#23
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                ControllerButtonHints.HideButtonHint(hand, hand.uiInteractAction);
                //hand.HideGrabHint();
            }
        }
示例#24
0
 // Use controller to control the ball
 private void HandHoverUpdate(Hand hand)
 {
     if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
     {
         if (hand.currentAttachedObject == ball)
         {
             hand.HoverLock(ballinter);
             hand.AttachObject(ball, attachmentFlags);
         }
     }
 }
示例#25
0
 private void HandHoverUpdate(Hand hand)
 {
     if (hand.GetStandardInteractionButtonDown())
     {
         hand.AttachObject(base.gameObject, this.attachmentFlags, this.attachmentPoint);
         ControllerButtonHints.HideButtonHint(hand, new EVRButtonId[]
         {
             EVRButtonId.k_EButton_Axis1
         });
     }
 }
示例#26
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = GrabTypes.None;

            startingGrabType = hand.GetGrabStarting(GrabTypes.Grip);

            if (startingGrabType != GrabTypes.None && PlayerToolkit.selectedTool == SoundStone_ToolTypes.Handtool)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
            }
        }
示例#27
0
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                initialMappingOffset = linearMapping.value - CalculateLinearMapping(hand.transform);
                sampleCount          = 0;
                mappingChangeRate    = 0.0f;
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
            }
        }
示例#28
0
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None && !WasUsed)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
                WasUsed = true;
                GetComponent <Interactable>().highlightOnHover = false;
            }
        }
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                if (startingGrabType == GrabTypes.Pinch)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, pinchOffset);
                }
                else if (startingGrabType == GrabTypes.Grip)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, gripOffset);
                }
                else
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                }

                hand.HideGrabHint();
            }
        }
示例#30
0
 private void OnHandHoverBegin(Hand hand)
 {
     if (!attached)
     {
         if (hand.GetStandardInteractionButton())
         {
             Rigidbody rb = GetComponent <Rigidbody>();
             if (rb.velocity.magnitude >= catchSpeedThreshold)
             {
                 hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
             }
         }
     }
 }