/// <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); }
/// <summary>Called by the hand whenever this item is grabbed</summary> public virtual void OnGrab(Hand hand) { if (lockHandOnGrab) { hand.GetComponent <Rigidbody>().isKinematic = true; } if (parentOnGrab) { body.transform.parent = hand.transform.parent; } heldBy?.Add(hand); throwing = false; beingHeld = true; ContinuousCollisionDetection(); gameObject.layer = LayerMask.NameToLayer("Holding"); onGrab?.Invoke(); if (placePoint != null) { placePoint.Remove(this); } OnGrabEvent?.Invoke(hand, this); }