public void Pickup(MoveableObject newItem) { if (item != null) { Drop(); } item = newItem; item.GetComponents <Rigidbody>() .ForAll(body => { body.useGravity = false; body.isKinematic = true; }); item.transform.parent = guide; }
public void Drop() { if (item != null) { if (item.isActiveAndEnabled) { item.GetComponents <Rigidbody>() .ForAll(body => { body.useGravity = true; body.isKinematic = false; }); item.transform.parent = transform.parent; item = null; } } }