//------------------------------------------------- protected virtual void HandAttachedUpdate(Hand hand) { 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 ) ); } if (scalingObject != null) { if (scalingObject.GetComponent <HairObject>().Grabbed) { float scale = (Vector3.Distance(transform.position, otherHand.transform.position) / startDistance) * scaleMultip; scale = Mathf.Clamp(scale, scaleMin, scaleMax); scalingObject.transform.localScale = new Vector3(scale, scale, scale); } } if (onHeldUpdate != null) { onHeldUpdate.Invoke(hand); } }
protected virtual void HandAttachedUpdate(Hand hand) { if (hand.IsGrabEnding(this.gameObject)) { print("GRIP > HAND ATTACHED UPDATE"); if (hand != null) { print("HAND NOT NULL"); } else { print("HAND NULL"); } //attachedHand = null; hand.DetachObject(this.gameObject, true); if (onDetachFromHand != null) { onDetachFromHand.Invoke(hand); } } weapon.heldUpdate(); if (onHeldUpdate != null) { onHeldUpdate.Invoke(hand); } }
/// <summary> /// Called when picking up this item /// </summary> public virtual void OnPickUp(Transform pickedUpByHand) { //internal stuff isPickedUp = true; //NOTE: REMEMBER TO USE RIGIDBODY.MovePosition instead of changing transform.position to avoid weird physics, or lack thereof body.isKinematic = true; transform.parent = pickedUpByHand.transform; //external stuff onPickup.Invoke(pickedUpByHand); }
/// <summary> /// Called when picking up this item /// </summary> public void OnPickUp(PhysicalObject pickedUpByHand) { //internal stuff //NOTE: REMEMBER TO USE RIGIDBODY.MovePosition instead of changing transform.position to avoid weird physics, or lack thereof body.isKinematic = true; //external stuff onPickUp.Invoke(pickedUpByHand); }
private void OnMessageReceived(object sender, MessageReceivedEventArgs e) { var message = JsonConvert.DeserializeObject <Message>(e.Message); switch (message.Header) { case "Join": var joinRes = JsonConvert.DeserializeObject <JoinRes>(message.Body); JoinEvent?.Invoke(this, new JoinEventArgs { JoinRes = joinRes }); break; case "Hand": var handRes = JsonConvert.DeserializeObject <HandRes>(message.Body); HandEvent?.Invoke(this, new HandEventArgs { HandRes = handRes }); break; case "Tsumo": var tsumoRes = JsonConvert.DeserializeObject <TsumoRes>(message.Body); TsumoEvent?.Invoke(this, new TsumoEventArgs { TsumoRes = tsumoRes }); break; case "Dahai": var dahaiRes = JsonConvert.DeserializeObject <DahaiRes>(message.Body); DahaiEvent?.Invoke(this, new DahaiEventArgs { DahaiRes = dahaiRes }); break; case "Agari": var agariRes = JsonConvert.DeserializeObject <AgariRes>(message.Body); AgariEvent?.Invoke(this, new AgariEventArgs { AgariRes = agariRes }); break; default: break; } }
private void OnActionChange(SteamVR_Action_In action) { if (m_Action.GetStateDown(m_Hand.handType) == true) { m_OnDown.Invoke(m_Hand); } else if (m_Action.GetStateUp(m_Hand.handType) == true) { m_OnUp.Invoke(m_Hand); } else if (m_Action.GetState(m_Hand.handType) == true) { m_OnHold.Invoke(m_Hand); } }
protected virtual void OnDetachedFromHand(Hand hand) { attached = false; onDetachFromHand.Invoke(hand); hand.HoverUnlock(null); GetComponent <Rigidbody>().interpolation = hadInterpolation; Vector3 velocity; Vector3 angularVelocity; GetReleaseVelocities(hand, out velocity, out angularVelocity); GetComponent <Rigidbody>().velocity = velocity; GetComponent <Rigidbody>().angularVelocity = angularVelocity; }
private void InvokeEvents(bool wasEngaged, bool isEngaged) { buttonDown = wasEngaged == false && isEngaged == true; buttonUp = wasEngaged == true && isEngaged == false; if (buttonDown && onButtonDown != null) { onButtonDown.Invoke(lastHoveredHand); } if (buttonUp && onButtonUp != null) { onButtonUp.Invoke(lastHoveredHand); } if (isEngaged && onButtonIsPressed != null) { onButtonIsPressed.Invoke(lastHoveredHand); } }
//------------------------------------------------- protected virtual void HandAttachedUpdate(Hand hand) { 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 ) ); } if (onHeldUpdate != null) { onHeldUpdate.Invoke(hand); } }
protected virtual void OnAttachedToHand(Hand hand) { //Debug.Log("<b>[SteamVR Interaction]</b> Pickup: " + hand.GetGrabStarting().ToString()); hadInterpolation = this.GetComponent <Rigidbody>().interpolation; attached = true; print("singleHandTool invoke on pickup"); onPickUp.Invoke(hand); hand.HoverLock(null); GetComponent <Rigidbody>().interpolation = RigidbodyInterpolation.None; //if (velocityEstimator != null) // velocityEstimator.BeginEstimatingVelocity(); //attachTime = Time.time; attachPosition = transform.position; attachRotation = transform.rotation; }
//------------------------------------------------- protected virtual void HandAttachedUpdate(Hand hand) { // CHANGE: added check for scripted grab type -> means that the release of the object es // managed separately and the object should not be released if the button is released if (hand.IsGrabEnding(this.gameObject) && GetGrabbingType(hand, this.gameObject) != GrabTypes.Scripted) { 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 ) ); } if (onHeldUpdate != null) { onHeldUpdate.Invoke(hand); } }
protected virtual void Update() { // move hand with keyboard string horizontalAxisName = "Horizontal"; string verticalAxisName = "Vertical"; float horizontalAxis = Input.GetAxisRaw(horizontalAxisName) * _horizontalSensibility; float verticalAxis = Input.GetAxisRaw(verticalAxisName) * _verticalSensibility; Vector2 handMovement = new Vector2(horizontalAxis, verticalAxis); //// move hand with mouse //if (Mathf.Approximately(handMovement.sqrMagnitude, 0f)) //{ // horizontalAxisName = "Mouse X"; // verticalAxisName = "Mouse Y"; // horizontalAxis = Input.GetAxisRaw(horizontalAxisName) * _horizontalMouseSensibility; // verticalAxis = Input.GetAxisRaw(verticalAxisName) * _verticalMouseSensibility; // handMovement = new Vector2(horizontalAxis, verticalAxis); //} transform.Translate(handMovement * Utils.GetDeltaTime(_deltaTimeType), Space.World); // clamp hand Vector2 position = transform.position; position.x = Mathf.Clamp(position.x, _horizontalBounds.x + _centerBounds.x, _horizontalBounds.y + _centerBounds.x); position.y = Mathf.Clamp(position.y, _verticalBounds.x + _centerBounds.y, _verticalBounds.y + _centerBounds.y); transform.position = position; string submitButtonName = "Submit";// string.Format("Submit {0}", (int)_playerIndex); if (Input.GetButtonDown(submitButtonName)) { _hold?.Invoke(this); } else if (Input.GetButtonUp(submitButtonName)) { _release?.Invoke(this); } }
protected virtual void HandHoverUpdate(Hand hand) { GrabTypes startingGrabType = hand.GetGrabStarting(); if (startingGrabType == GrabTypes.Grip || (startingGrabType == GrabTypes.Pinch && allowPinchGrab)) { print("GRIP > HAND HOVER UPDATE "); if (hand != null) { print("HAND NOT NULL"); } else { print("HAND NULL"); } //attachedHand = hand; hand.AttachObject(this.gameObject, GrabTypes.Grip, Hand.AttachmentFlags.ParentToHand | Hand.AttachmentFlags.SnapOnAttach, null); if (onPickUp != null) { onPickUp.Invoke(hand); } } }
public void OnHandHoverStart(Hand hand) { onHandHoverStart.Invoke(hand); }
public void OnHandHoverEnd(Hand hand) { onHandHoverEnd.Invoke(hand); }
public void OnInterActionEnd(Hand hand) { onInteractionEnd.Invoke(hand); }
public void OnInteractionStart(Hand hand) { onInteractionStart.Invoke(hand); }