private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.GetComponent <ObstacleGrab>() != null && objectInField != null) { objectInField = null; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <ObstacleGrab>() != null) { objectInField = collision.gameObject.GetComponent <ObstacleGrab>(); } Debug.Log(collision.gameObject.tag); }
public void Grab() { if (grabbedObject == null) { if (objectInField != null) { grabbedObject = objectInField; transform.parent.GetComponent <Rigidbody2D>().simulated = false; grabbedObject.OnGrab(transform); transform.parent.GetComponent <Rigidbody2D>().simulated = true; } } else { grabbedObject.OnRelease(); grabbedObject = null; } }