void FreeBox() { if (ControlledBox != null) { ControlledBox.GetComponent <Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Discrete; ControlledBox.enabled = false; ControlledBox = null; ControlledBoxStats = null; } }
void CatchBox(GameObject Target) { if (Target != null) { ControlledBoxStats = Target.GetComponent <BoxStats>(); ControlledBox = Target.GetComponent <RelativeJoint2D>(); if (ControlledBoxStats.State.State == BoxState.Losted) { FreeBox(); } else { ControlledBox.GetComponent <Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Continuous; ControlledBox.connectedBody = GetComponent <Rigidbody2D>(); ControlledBox.enabled = true; } } }