Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

touch and collision not wroking

Discussion in '2D' started by Rikku321, May 6, 2014.

  1. Rikku321

    Rikku321

    Joined:
    Apr 12, 2014
    Posts:
    13
    hey guys, im making a 2d game for android, im moving an object and when it touch a box a i want some thing to happent, but it dosent seem to work.

    code:

    Code (csharp):
    1.  
    2. function OnCollisionEnter2D(coll: Collision2D) {
    3.     if (coll.gameObject.tag == "Origin")
    4.     {
    5.     Debug.Log ("4");
    6.         drawGUI = true;
    7.     }
    8. }
    9.  
     
  2. cbothra

    cbothra

    Joined:
    Mar 14, 2014
    Posts:
    125
    Make sure that you have added the BoxCollider 2d to both the objects.
     
  3. Rikku321

    Rikku321

    Joined:
    Apr 12, 2014
    Posts:
    13
    i fixed it with on trigger enter and checking the triger when i need.