//-------------------------------------------------
        // Called every Update() while a Hand is hovering over this object
        //-------------------------------------------------
        // Modified.
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabEnding(this.gameObject);

            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                transform.SetParent(null);
                // 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.SetParent(GameObject.Find("Automatic Cameras").transform);
            }
        }
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            if (takeBackItem && requireReleaseActionToReturn)
            {
                if (hand.isActive)
                {
                    ItemPackage currentAttachedItemPackage = GetAttachedItemPackage(hand);
                    if (currentAttachedItemPackage == itemPackage && hand.IsGrabEnding(currentAttachedItemPackage.gameObject))
                    {
                        Debug.Log("returning");
                        TakeBackItem(hand);
                        return;                         // So that we don't pick up an ItemPackage the same frame that we return it
                    }
                }
            }

            if (requireGrabActionToTake)
            {
                GrabTypes startingGrab = hand.GetGrabStarting();

                if (startingGrab != GrabTypes.None)
                {
                    SpawnAndAttachObject(hand, GrabTypes.Scripted);
                }
            }
        }
예제 #3
0
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            //Start Block pulling if the Block is grabbed Block is Indirectly connected to Floor or Hand
            if (startingGrabType != GrabTypes.None && (GetComponent <BlockCommunication>().IsIndirectlyAttachedToFloor() || GetComponent <BlockCommunication>().IsIndirectlyAttachedToHand()) && !GetComponent <Interactable>().isMarked)
            {
                pullingHand     = hand;
                pullingGrabType = startingGrabType;
                Debug.Log("Attaching To Hand");
            }

            //Grabbed a Marked Block so copy the structure and grab the copied Block
            else if (startingGrabType != GrabTypes.None && GetComponent <BlockCommunication>().IsIndirectlyAttachedToFloor() && GetComponent <Interactable>().isMarked)
            {
                GameObject block = GameObject.FindGameObjectWithTag("BlockMarker").GetComponent <BlockMarker>().RebuildMarkedStructure(this.gameObject);
                StartCoroutine(AttachNewBlockToHand(block, hand));
                Debug.Log("Attaching To Hand");
            }

            //Loose Block, can be directly attached to hand
            else if (startingGrabType != GrabTypes.None)
            {
                Debug.Log("Attaching To Hand");
                PhysicsAttach(hand, startingGrabType);
            }
        }
    //-------------------------------------------------
    // 当手一直悬停在可交互物体上,被每帧调用
    //-------------------------------------------------
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();    //获取手柄进行抓取的方式

        bool isGrabEnding = hand.IsGrabEnding(this.gameObject); //获取手柄是否结束抓取

        if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
        {
            // 保存位置/旋转,当分离时,以便可以恢复它。
            oldPosition = transform.position;
            oldRotation = transform.rotation;


            //锁定该交互物,避免再悬停到其他物体上,保证一次悬停锁定一个可交互的物体
            hand.HoverLock(interactable);

            // 附加该物体到手上
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
        }
        else if (isGrabEnding)
        {
            // 从手上分离该物体
            hand.DetachObject(gameObject);

            // 解除对该物体的悬停锁定
            hand.HoverUnlock(interactable);

            // 恢复分离的物体到原来的位置
            transform.position = oldPosition;
            transform.rotation = oldRotation;
        }
    }
        //-------------------------------------------------
        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();
            }
        }
예제 #6
0
 private void ResetPullingState()
 {
     wasPulled       = false;
     pullingHand     = null;
     pullingGrabType = GrabTypes.None;
     GetComponent <LineRenderer>().enabled = false;
 }
예제 #7
0
        //-------------------------------------------------
        private void FireArrow()
        {
            currentArrow.transform.parent = null;

            var arrow = currentArrow.GetComponent <Arrow>();

            arrow.shaftRB.isKinematic = false;
            arrow.shaftRB.useGravity  = true;
            arrow.shaftRB.transform.GetComponent <BoxCollider>().enabled = true;

            arrow.arrowHeadRB.isKinematic = false;
            arrow.arrowHeadRB.useGravity  = true;
            arrow.arrowHeadRB.transform.GetComponent <BoxCollider>().enabled = true;

            arrow.arrowHeadRB.AddForce(currentArrow.transform.forward * bow.GetArrowVelocity(), ForceMode.VelocityChange);
            arrow.arrowHeadRB.AddTorque(currentArrow.transform.forward * 10);

            nocked         = false;
            nockedWithType = GrabTypes.None;

            currentArrow.GetComponent <Arrow>().ArrowReleased(bow.GetArrowVelocity());
            bow.ArrowReleased();

            allowArrowSpawn = false;
            Invoke("EnableArrowSpawn", 0.5f);
            StartCoroutine(ArrowReleaseHaptics());

            currentArrow = null;
            allowTeleport.teleportAllowed = true;
        }
예제 #8
0
        //-------------------------------------------------
        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
        private void HandleControllerInput()
        {
            for (int i = 0; i < hands.Length; i++)
            {
                GrabTypes starting = hands[i].GetGrabStarting();
                if (starting != GrabTypes.None)
                {
                    hands[i].GetComponent <InputOTouch>().isGrabing = true;
                    hands[i].GetComponent <InputOTouch>().grabType  = starting;
                    ConditionPublisher.Instance.Send(new OTouchDownState(this, (int)starting));
                }

                GrabTypes ending = hands[i].GetGrabEnding();
                if (ending != GrabTypes.None)
                {
                    hands[i].GetComponent <InputOTouch>().isGrabing = false;
                    ConditionPublisher.Instance.Send(new OTouchUpState(this, (int)ending));
                }
                else
                {
                    if (hands[i].GetComponent <InputOTouch>().isGrabing)
                    {
                        ConditionPublisher.Instance.Send(new OTouchHoldState(this, (int)hands[i].GetComponent <InputOTouch>().grabType));
                    }
                }
            }
        }
예제 #10
0
파일: Key.cs 프로젝트: Booradley/ggj-2020
        private void HandHoverUpdate(Hand hand)
        {
            // Don't allow interaction when unwinding
            if (_state == KeyState.Unwinding)
            {
                return;
            }

            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabEnding(gameObject);

            if (_interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                hand.HoverLock(_interactable);
                hand.AttachObject(gameObject, startingGrabType, _attachmentFlags);

                _grabbingHand = hand;
                _state        = KeyState.Winding;
            }
            else if (isGrabEnding)
            {
                hand.DetachObject(gameObject);
                hand.HoverUnlock(_interactable);

                _grabbingHand = null;
                _state        = KeyState.Windable;
            }
        }
예제 #11
0
    protected override void HandHoverUpdate(Hand hand)
    {
        // Allowing this before checking Objective state so that Throwable can cleanup easier
        if (attachEaseIn)
        {
            float t = Util.RemapNumberClamped(Time.time, attachTime, attachTime + snapAttachEaseInTime, 0.0f, 1.0f);
            if (t < 1.0f)
            {
                t = snapAttachEaseInCurve.Evaluate(t);
                transform.position = Vector3.Lerp(attachPosition, attachEaseInTransform.position, t);
                transform.rotation = Quaternion.Lerp(attachRotation, attachEaseInTransform.rotation, t);
            }
            else if (!snapAttachEaseInCompleted)
            {
                gameObject.SendMessage("OnThrowableAttachEaseInCompleted", hand, SendMessageOptions.DontRequireReceiver);
                snapAttachEaseInCompleted = true;
            }
        }


        if (objectiveState == Objective.ObjectiveStates.InProgress)
        {
            // when in an objective

            GrabTypes startingGrabType = hand.GetGrabStarting();
            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                // Attach this object to the hand

                if (startingGrabType == GrabTypes.Pinch)
                {
                    hand.AttachObject(gameObject, startingGrabType, base.attachmentFlags, pinchAttachOffset);
                }
                else if (startingGrabType == GrabTypes.Grip)
                {
                    hand.AttachObject(gameObject, startingGrabType, base.attachmentFlags, gripAttachOffset);
                }
                else
                {
                    hand.AttachObject(gameObject, startingGrabType, base.attachmentFlags, base.attachmentOffset);
                }

                hand.HideGrabHint();
                if (ObjectiveType == Objective.PartObjectiveTypes.MoveToLocation)
                {
                    // Do nothing
                }
                else if (ObjectiveType == Objective.PartObjectiveTypes.MoveFromLocation)
                {
                    UpdatePlacementState(PlacementStates.DefaultPlaced);
                }
            }
        }
        else if (objectiveState == Objective.ObjectiveStates.NotInProgress)
        {
            // when outside of an objective
            // TODO make obtion for acting throwable
        }
    }
예제 #12
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None && isOpen == false)
        {
            doorAnimator.SetBool("character_nearby", true);
        }
    }
예제 #13
0
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
            }
        }
예제 #14
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            PhysicsAttach(hand, startingGrabType);
        }
    }
예제 #15
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            sabitle();
        }
    }
예제 #16
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            valveIsOpened = !valveIsOpened;
        }
    }
    public override void HandHoverUpdate(Hand hand)
    {
        GrabTypes bestGrabType = hand.GetBestGrabbingType();

        if (bestGrabType != GrabTypes.None && rtTransform.ownerID == -1)
        {
            hand.AttachObject(gameObject, bestGrabType, attachmentFlags);
        }
    }
예제 #18
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            VRCharController.leftForklift(detectButton());
        }
    }
예제 #19
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
        {
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
        }
    }
예제 #20
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None && isOn == false)
        {
            particles.SetActive(true);
        }
    }
예제 #21
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
            m_turret.GetComponent <TurretController>().AttachHand(hand);
        }
    }
예제 #22
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();
            }
        }
예제 #23
0
        /// this magic method is called by hand while hovering
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, Hand.AttachmentFlags.DetachFromOtherHand | Hand.AttachmentFlags.ParentToHand);
                OnGrab?.Invoke();
            }
        }
예제 #24
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            print("should remove");
            RemoveAllAttachments();
        }
    }
예제 #25
0
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (_interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                _interactable.enabled = false;
                OnLidGrabbed?.Invoke();
            }
        }
예제 #26
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            testScripts.izgaraInitiated();
            VRUIController.showDof1();
        }
    }
예제 #27
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None)
        {
            m_heldHand = hand;
            Teleport.Player.AddListener(TeleportBringAttachedObjects);
        }
    }
예제 #28
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();
            }
        }
예제 #29
0
    protected virtual void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();

        if (startingGrabType != GrabTypes.None && (potteryM.state == PotteryManager.State.Combed || potteryM.state == PotteryManager.State.GrabedHand))
        {
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
            potteryM.state = PotteryManager.State.GrabedHand;
        }
    }
예제 #30
0
    private void HandHoverUpdate(Hand hand)
    {
        GrabTypes startingGrabType = hand.GetGrabStarting();
        bool      isGrabEnding     = hand.IsGrabEnding(this.gameObject);

        if (startingGrabType != GrabTypes.None)
        {
            GameManager.instance.HitMud = false;
        }
    }