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

Collider Problems - C#

Discussion in 'Scripting' started by JackaJacka, Jun 19, 2014.

  1. JackaJacka

    JackaJacka

    Joined:
    Mar 20, 2014
    Posts:
    9
    Hello! I have encountered lots of problems with colliders in Unity. I have a 2D project and I want a object to act upon touching or, colliding. I am just testing to see if it does anything, and the code that I have is correct; I have confirmed it with many sources and books. It doesn't seem to do anything though. I have created its own script for itself so it shouldn't be because of the code. Here is the code that I have:

    Code (CSharp):
    1. void OnTriggerEnter(Collider other){
    2.         Debug.Log ("This better work.");
    3.         if(other.gameObject.tag == "Player"){
    4.             CoinFall.Touching = true;
    5.         }
    6.     }
    Why is this not working? They are in the same z plane and they are touching each other, though it never responds.

    Help?

    Thanks!

    -Jack
     
  2. zaxvax

    zaxvax

    Joined:
    Jun 9, 2012
    Posts:
    220
    if you are using 2D system from Unity, then there is a bunch of twins for 3D classes.
    Such as BoxCollider2D , CircleCollider2D , HingeJoint2D and so on.
    And you are supposed to use them with 2D objects.
     
  3. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    226
    JackaJacka likes this.
  4. JackaJacka

    JackaJacka

    Joined:
    Mar 20, 2014
    Posts:
    9