Search Unity

Simple 2D Triggers Not Working

Discussion in 'Physics' started by fsoufi, Aug 26, 2015.

  1. fsoufi

    fsoufi

    Joined:
    Apr 5, 2012
    Posts:
    37
    Hello,
    I searched a lot about my problem all i found issues were addressed in 2013 and fixed in unity v4.5, however my problem still exist.
    I am doing a very simple 2 sprites (bullet and a spaceship) with 2Drigidbody (for velocity movement) (isKinmatic disabled on both) and with 2D polygon colliders marked both as triggers.
    I used :
    Code (csharp):
    1.  
    2.  public void OnTriggrEnter2D(Collider2D collision)
    3.     {
    4.         Debug.Log(collision.gameObject.name);
    5.  
    6.        // if (collision.gameObject.tag == "Enemy")
    7.         //{
    8.             //Instantiate(spark, transform.position, transform.rotation);
    9.         //}
    10.         // Destroy(this.gameObject);
    11.  
    12.     }
    13.  
    I had high hopes to get it to work from the first time .. but then I commented out all the action of sparks / explosions, yet not even debug.log is working
    what am I doing wrong ?!
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    You wrote OnTriggrEnter instead of OnTriggerEnter. Notice the e missing?
     
    fsoufi likes this.
  3. fsoufi

    fsoufi

    Joined:
    Apr 5, 2012
    Posts:
    37
    oh god, this thing got me insane yesterday, I am at work atm, so I will check it when i get back to my house.
    and for the info, I didn't write it myself, I used *implement something something* from visual studio, and it writes the function for me, I wonder how did it miss spell o_O
     
  4. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Maybe the unity plugin for vs is wrong, try to see, if they updated it.
     
  5. fsoufi

    fsoufi

    Joined:
    Apr 5, 2012
    Posts:
    37
    Hi thanks for your help it is working fine now, not it is not wrong , i must have deleted e by mistake ? .. and maybe i then copied the whole method and started pasting it instead of using (implement monobehavior).