Search Unity

[Help] Guitar Hero-esque code not working.

Discussion in 'Scripting' started by Shrockoz, Oct 13, 2015.

  1. Shrockoz

    Shrockoz

    Joined:
    Oct 17, 2013
    Posts:
    2
    Code (CSharp):
    1.     void OnTriggerStay2D (Collider2D other) {
    2.         Debug.Log("Test");
    3.         if (Input.GetKeyDown("D"))
    4.         {
    5.             if (other.gameObject.tag == "ZoneWin")
    6.  
    7.             {
    8.                 Destroy(gameObject);
    9.             }
    10.         }
    11.        
    12.     }
    13. }
    I have the correct tags, correct everything as far as I can see. However, my gameObject just passes through the other sprite I put in. (This code is on the object that I am Instantiating.)
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    does something involved have a rigidbody2d attached?
     
  3. Shrockoz

    Shrockoz

    Joined:
    Oct 17, 2013
    Posts:
    2
    Yes, my "ZoneWin" sprite has a rigid body.