/// <summary>Called by the hand whenever this item is grabbed</summary> public virtual void OnGrab(Hand hand) { placePoint?.Remove(this); placePoint = null; if (lockHandOnGrab) { hand.GetComponent <Rigidbody>().isKinematic = true; } body.interpolation = RigidbodyInterpolation.Interpolate; if (!body.isKinematic) { body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } else { body.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; } if (parentOnGrab) { body.transform.parent = hand.transform.parent; } heldBy?.Add(hand); throwing = false; beingHeld = true; onGrab?.Invoke(); OnGrabEvent?.Invoke(hand, this); }
public void OnTriggerEnter(Collider other) { if (heldBy.Count > 0 && other.GetComponent <PlacePoint>()) { var otherPoint = other.GetComponent <PlacePoint>(); if (otherPoint == null) { return; } if (placePoint != null && placePoint.PlacedObject() != null) { return; } if (placePoint == null || otherPoint.Distance(transform) < placePoint.Distance(transform)) { if (otherPoint.CanPlace(transform)) { placePoint = other.GetComponent <PlacePoint>(); placePoint.Highlight(); if (placePoint.callGrabbableHighlight) { Highlight(); } } } } }
public void OnTriggerExit(Collider other) { if (heldBy.Count > 0 && placePoint != null && placePoint == other.GetComponent <PlacePoint>()) { placePoint.StopHighlight(); if (placePoint.callGrabbableHighlight) { Unhighlight(); } placePoint = null; } }
public void OnTriggerEnter(Collider other) { if (other.GetComponent <PlacePoint>()) { var otherPoint = other.GetComponent <PlacePoint>(); if (heldBy.Count == 0 && !otherPoint.onlyPlaceWhileHolding) { return; } if (otherPoint == null) { return; } if (placePoint != null && placePoint.GetPlacedObject() != null) { return; } if (placePoint == null) { if (otherPoint.CanPlace(transform)) { placePoint = other.GetComponent <PlacePoint>(); if (placePoint.forcePlace) { if (lastPlacePoint == null || (lastPlacePoint != null && !lastPlacePoint.Equals(placePoint))) { ForceHandsRelease(); placePoint.Place(this); lastPlacePoint = placePoint; } } else { placePoint.Highlight(this); if (placePoint.grabbableHighlight) { Highlight(heldBy[0]); } } } } } }
public void OnTriggerExit(Collider other) { if (other.GetComponent <PlacePoint>() == null) { return; } if (placePoint != null && placePoint.Equals(other.GetComponent <PlacePoint>()) && placePoint.Distance(transform) > 0.01f) { placePoint.StopHighlight(this); if (placePoint.grabbableHighlight) { Unhighlight(heldBy[0]); } placePoint = null; } if (lastPlacePoint != null && lastPlacePoint.Equals(other.GetComponent <PlacePoint>()) && Vector3.Distance(lastPlacePoint.transform.position, transform.position) > lastPlacePoint.placeRadius) { lastPlacePoint = null; } }
internal void SetPlacePoint(PlacePoint point) { placePoint = point; }
public void SetPlacePoint(PlacePoint point) { placePoint = point; }