Search Unity

Unity 5.5 OnTriggerEnter2D not working

Discussion in '2D' started by Phinion, Feb 23, 2017.

  1. Phinion

    Phinion

    Joined:
    Feb 16, 2017
    Posts:
    1
    I have a player and an exit.
    Player - size 1 x 1:
    BoxCollider2D - With no trigger. Size 1x1
    RigidBody2D - Dynamic Body Type. No Gravity. Collision Detection Discrete.
    Script on player:

    private void OnTriggerEnter2D (Collider2D other)
    {
    Debug.Log (other.gameObject.name);
    CanMove = false; //Stops player moving.
    }

    Exit - size 1 x 1:
    BoxCollider2D - Trigger on. Size 1 x 1

    I run the game and i move the player onto the exit but it still moves. And Debug.log doesnt show.
    Idk what ive done wrong?
     
  2. Manato

    Manato

    Joined:
    Jun 11, 2015
    Posts:
    28
    There is nothing wrong.
    I think some of your configuration are not set correctly.
    Check if you are really using 2DCollider and 2dRigidbody.

    Otherwise isolate the problem. If you still have the problem post the full context (of the isolate version).
     
    vakabaka likes this.
  3. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    yes, this code is working

    and check, are the messages enabled in the console (open console window and look at exclamation mark in up-right side)?