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

Why won't this trigger work??

Discussion in '2D' started by tennisboy08, Mar 14, 2015.

  1. tennisboy08

    tennisboy08

    Joined:
    Feb 16, 2015
    Posts:
    24
    I have tried so many different things and cannot get the trigger to work. I test it to say something to the console when it does but it never works.

    Here is a picture of the character components
    error1.PNG

    Here is a picture of the trigger components
    error2.PNG

    here is the code I'm using to test if it triggers
    Code (JavaScript):
    1. function OnCollisionEnter(){
    2.     Debug.Log("Triggered");
    3. }
     
  2. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    If You want to collide two objects, both must have colliders. Your Penguin don't have. Just add collider2d to him.

    And use OnTriggerEnter2d insdead of OnCollisionEnter.
     
  3. tennisboy08

    tennisboy08

    Joined:
    Feb 16, 2015
    Posts:
    24
    Thank You it works now!