//------------------------------------------------- // 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); } } }
//------------------------------------------------- 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(); } }
private void ResetPullingState() { wasPulled = false; pullingHand = null; pullingGrabType = GrabTypes.None; GetComponent <LineRenderer>().enabled = false; }
//------------------------------------------------- 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; }
//------------------------------------------------- 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); } }
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)); } } } }
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; } }
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 } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None && isOpen == false) { doorAnimator.SetBool("character_nearby", true); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { PhysicsAttach(hand, startingGrabType); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { sabitle(); } }
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); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { VRCharController.leftForklift(detectButton()); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { hand.AttachObject(gameObject, startingGrabType, attachmentFlags); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None && isOn == false) { particles.SetActive(true); } }
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); } }
//------------------------------------------------- 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(); } }
/// 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(); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { print("should remove"); RemoveAllAttachments(); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (_interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { _interactable.enabled = false; OnLidGrabbed?.Invoke(); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { testScripts.izgaraInitiated(); VRUIController.showDof1(); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { m_heldHand = hand; Teleport.Player.AddListener(TeleportBringAttachedObjects); } }
//------------------------------------------------- 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(); } }
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; } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabEnding(this.gameObject); if (startingGrabType != GrabTypes.None) { GameManager.instance.HitMud = false; } }