Search Unity

Trigger not working

Discussion in '2D' started by omriysh, Feb 20, 2015.

  1. omriysh

    omriysh

    Joined:
    Sep 3, 2014
    Posts:
    4
    Hello

    I am creating a new 2d arcade game, where I want the player to pick up a diamond. The view is from the top, so there are no physics involved. Both the player game object and the diamond object include transforms, 2d colliders (box for player, triger circle on diamond), rigidbody 2d (both have gravity scale set to 0, and the diamond has kinematic on), sprite renderers (both are in less than 16x16 pixels, so the camera is zoomed in) and animators. I both have this script attached:

    using UnityEngine;
    using System.Collections;

    public class PickingUp : MonoBehaviour
    {
    public Transform player; //assigned in inspector
    void OnTriggerEnter (Collider other)
    {
    Debug.Log("collided");
    Instantiate(player, new Vector3 (0, 0, 0), Quaternion.identity);
    Destroy(this.gameObject);
    }
    }


    For some reason unknowned to me this isn't working.
    can someone help me understand why?

    Thank you.
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Shouldn't that be OnTriggerEnter2D()?
     
    omriysh likes this.
  3. omriysh

    omriysh

    Joined:
    Sep 3, 2014
    Posts:
    4
    Thank you soooo much.... I feel so stupid for missing this....