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); } } } }
//------------------------------------------------- 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 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); } }
//------------------------------------------------- protected virtual void HandAttachedUpdate(Hand hand) { if (!toggleGrab) { if (hand.IsGrabEnding(this.gameObject)) { hand.DetachObject(gameObject, restoreOriginalParent); // Uncomment to detach ourselves late in the frame. // This is so that any vehicles the player is attached to // have a chance to finish updating themselves. // If we detach now, our position could be behind what it // will be at the end of the frame, and the object may appear // to teleport behind the hand when the player releases it. //StartCoroutine( LateDetach( hand ) ); } } else { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType == GrabTypes.Grip) { hand.DetachObject(gameObject, restoreOriginalParent); } } if (onHeldUpdate != null) { onHeldUpdate.Invoke(hand); } }
//------------------------------------------------- // 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; } }
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); } } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { if (takeBackItem && requireReleaseActionToReturn) { if (hand.isActive) { ItemPackage currentAttachedItemPackage = GetAttachedItemPackage(hand); if (currentAttachedItemPackage == itemPackage && hand.IsGrabEnding(currentAttachedItemPackage.gameObject)) { 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); } } }
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) { var startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { PhysicsAttach(hand, startingGrabType); } }
//------------------------------------------------- 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) { hand.AttachObject(gameObject, startingGrabType, attachmentFlags, hand.name == "LeftHand" ? attachmentOffsetLeft : attachmentOffsetRight); hand.HideGrabHint(); } }
//------------------------------------------------- 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(); } }
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 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(); } }
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); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { //Debug.Log(hand.gameObject.name + " Hover Update"); GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabStarting = startingGrabType != GrabTypes.None; bool isGrabbing = hand.IsGrabbing(); bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false; if (isGrabStarting || (grabbingHand == null && isGrabbing)) // Grab Start //Debug.Log(" Grab Start! (" + Time.frameCount + ")"); //if (grabbingHand != null) { // Another hand has already grabbed -> switch hands // Debug.Log(" (switching hands)"); //} { lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; grabbedWithType = hand.GetBestGrabbingType(GrabTypes.Grip); grabbingHand = hand; isGrabEnding = false; } else if (isGrabEnding && grabbingHand == hand) // Grab End //Debug.Log(" Grab End! (" + Time.frameCount + ")"); { if (hoverLock) { hand.HoverUnlock(interactable); handHoverLocked = null; } driving = false; grabbedWithType = GrabTypes.None; grabbingHand = null; } if (grabbingHand == hand) { //Debug.Log(" Grab Update!"); ComputeAngle(hand); UpdateAll(); } }
private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { //if (movingPart.localPosition.x <= -1.29) //{ // movingPart.localPosition = new Vector3(-1.2f, 0.000f, 1.616f); // print("local position drag: " + movingPart.localPosition.x); // movingPart.Translate(-1.29f, 0.000f, 1.616f); //} hand.AttachObject(gameObject, startingGrabType, attachmentFlags); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false; if (grabbedWithType == GrabTypes.None && startingGrabType != GrabTypes.None) { grabbedWithType = startingGrabType; // Trigger was just pressed lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; DriveBegin?.Invoke(); ComputeAngle(hand); UpdateAll(); hand.HideGrabHint(); } else if (grabbedWithType != GrabTypes.None && isGrabEnding) { // Trigger was just released if (hoverLock) { hand.HoverUnlock(interactable); handHoverLocked = null; } driving = false; DriveEnd?.Invoke(); grabbedWithType = GrabTypes.None; } if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable) { ComputeAngle(hand); UpdateAll(); } }
/** STEAMVR SYSTEM ROUTINES **/ protected virtual void HandHoverUpdate(Hand hand) { // We want to handle potentially picking up a tower that has been placed at this node // Capture current grab information from the hand GrabTypes startingGrabType = hand.GetGrabStarting(); // If the hand is grabbing and there is a tower here to be grabbed if (attachedTower != null && startingGrabType != GrabTypes.None && !da.isDived()) { // Remove the tower and attach it to the hand TowerObject temp = attachedTower; RemoveTower(); hand.AttachObject(temp.gameObject, startingGrabType, temp.attachmentFlags, temp.attachentOffset); hand.HideGrabHint(); } }
//------------------------------------------------- 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(); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { if (requireGrabActionToTake) { GrabTypes startingGrab = hand.GetGrabStarting(); if (startingGrab != GrabTypes.None) { RemoveAllItemsFromHandStack(hand); if (emptyBothHands) { RemoveAllItemsFromHandStack(hand.otherHand); } } } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType == GrabTypes.Grip) { if (hand.otherHand.currentAttachedObject != gameObject) { hand.AttachObject(gameObject, GrabTypes.Grip, Hand.AttachmentFlags.ParentToHand | Hand.AttachmentFlags.SnapOnAttach | Hand.AttachmentFlags.TurnOffGravity, null); } else { //hand.AttachObject( gameObject, GrabTypes.Grip, 0 , null); //SteamVR_Skeleton_PoseSnapshot pose = attachedObject.interactable.skeletonPoser.GetBlendedPose(skeleton); } } }
protected virtual void HandHoverUpdate(Hand hand) { // Capture current grab information from the hand GrabTypes startingGrabType = hand.GetGrabStarting(); // Check if we are not currently attached and are being grabbed if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { // Attach to the hand hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachentOffset); hand.HideGrabHint(); if (crtRespawn != null) { StopCoroutine(crtRespawn); } } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None) { // Trigger was just pressed lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; hand.AttachObject(gameObject, startingGrabType, attachmentFlags); hand.HideGrabHint(); } }
//------------------------------------------------- protected virtual void OnAttachedToHand(Hand hand) { Debug.Log("<b>[SteamVR Interaction]</b> Pickup: " + hand.GetGrabStarting().ToString()); lastUsedHand = hand; hadInterpolation = this.rigidbody.interpolation; attached = true; onPickUp.Invoke(); if (!hoverLockIfGrabbed) { hand.HoverUnlock(null); } else { hand.HoverLock(null); } rigidbody.interpolation = RigidbodyInterpolation.None; velocityEstimator.BeginEstimatingVelocity(); attachTime = Time.time; attachPosition = transform.position; attachRotation = transform.rotation; if (hand.m_IndexFingerCollider != null) { hand.m_IndexFingerCollider.enabled = false; } if (dontLetGoOnInputUp) { m_inputUpIgnored = 0; } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { /*ItemPackage currentAttachedItemPackage = GetAttachedItemPackage(hand); * * if (currentAttachedItemPackage == itemPackage) // the item at the top of the hand's stack has an associated ItemPackage * { * if (takeBackItem && requireReleaseActionToReturn) // if we want to take back matching items and aren't waiting for a trigger press * { * if (releaseGun.GetStateDown(SteamVR_Input_Sources.RightHand) || releaseGun.GetStateDown(SteamVR_Input_Sources.LeftHand)) * { * TakeBackItem(hand); * } * } * }*/ /*if (takeBackItem && requireReleaseActionToReturn) * { * * if (hand.isActive) * { * ItemPackage currentAttachedItemPackage = GetAttachedItemPackage(hand); * if (currentAttachedItemPackage == itemPackage && hand.IsGrabEnding(currentAttachedItemPackage.gameObject)) * { * 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); } } }
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(); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabEnding(this.gameObject); if (startingGrabType != GrabTypes.None) { // Trigger was just pressed lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; ComputeAngle(hand); UpdateAll(); hand.HideGrabHint(); } if (isGrabEnding) { // Trigger was just released if (hoverLock) { hand.HoverUnlock(interactable); handHoverLocked = null; } } else if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable) { ComputeAngle(hand); UpdateAll(); } }
protected override void HandHoverUpdate(Hand hand) { GameObject flashlight = GameObject.Find("Light_flashlight"); GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType != GrabTypes.None) { if (startingGrabType == GrabTypes.Pinch) { flashlight.GetComponent <Light>().enabled = true; 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(); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { // ebaender worldPlaneNormal = new Vector3(0f, 0f, 0f); worldPlaneNormal[(int)axisOfRotation] = 1.0f; // ebaender if (transform.parent) { worldPlaneNormal = transform.parent.localToWorldMatrix.MultiplyVector(worldPlaneNormal).normalized; } GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false; currentCoverLimit = Book.coverMapping.value * Book.hingeMaxLimit; if (grabbedWithType == GrabTypes.None) { if (startingGrabType == GrabTypes.Pinch && hand == Player.instance.leftHand) { grabbedWithType = startingGrabType; // Trigger was just pressed lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; ComputeSimpleAngle(hand); UpdateAll(); hand.HideGrabHint(); // ebaender - attach hand hand.AttachObject(gameObject, startingGrabType, attachmentFlags); } else if (startingGrabType == GrabTypes.Grip) { if (hand == Player.instance.rightHand && hand.LastCollider.GetComponent <PageHandle>().handleType == PageHandle.Type.Back) { hand.LastCollider = Book.lowerBackHandle.GetComponent <Collider>(); hand.LastCollider.GetComponentInParent <BookThrowable>().SendMessage("HandHoverUpdate", hand); } else if (hand == Player.instance.leftHand && hand.LastCollider.GetComponent <PageHandle>().handleType == PageHandle.Type.Cover) { if (Book.pagePhysicsController.AttachedToBack) { hand.LastCollider = Book.lowerCoverHandle.GetComponent <Collider>(); hand.LastCollider.GetComponentInParent <CoverDrive>().SendMessage("HandHoverUpdate", hand); } } } } else if (grabbedWithType != GrabTypes.None && isGrabEnding) { // Trigger was just released if (hoverLock) { hand.HoverUnlock(interactable); handHoverLocked = null; } driving = false; grabbedWithType = GrabTypes.None; // ebaender - detach hand hand.DetachObject(gameObject); } if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable) { ComputeSimpleAngle(hand); UpdateAll(); } }