Example #1
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <ObstacleGrab>() != null && objectInField != null)
     {
         objectInField = null;
     }
 }
Example #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <ObstacleGrab>() != null)
     {
         objectInField = collision.gameObject.GetComponent <ObstacleGrab>();
     }
     Debug.Log(collision.gameObject.tag);
 }
Example #3
0
 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;
     }
 }