Search Unity

Instantiating gameobjects at a location with a variable value.

Discussion in 'Scripting' started by chadduffin, Jan 22, 2014.

  1. chadduffin

    chadduffin

    Joined:
    Jan 22, 2014
    Posts:
    1
    Hi guys, I am trying to make a block increment it's shrink variable when it is in collision with an explosion object, and keep incrementing it for as long as it stays in collision. My code outputs "I should be breaking." but it does not manage to make it to the actual incrementation. Any ideas? Thank you for your help.

    Code (csharp):
    1. void OnCollisionStay2D(Collision2D explosion) {
    2.         Debug.Log("I should be breaking.");
    3.         if (explosion.gameObject.tag == "Respawn") {
    4.             shrink++;
    5.         }
    6.     }
     
    Last edited: Jan 22, 2014