Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Limiting interaction with buttons

Discussion in 'Scripting' started by RBB, Jun 3, 2011.

  1. RBB

    RBB

    Joined:
    Apr 12, 2011
    Posts:
    35
    I have 03 buttons and the player must figure out the sequence. After making his attempt, the script checks the order and restart the game or to move to next stage. How can I do to prevent that the same button be pressed more than once. How to stop the player to press the same button again?

    I create this script but not work:

    Code (csharp):
    1. var bt1 = false;
    2. var bt2 = false;
    3. var bt3 = false;
    4.  
    5.     if (hit.gameObject.tag == "button") {
    6.         if (bt1 == true)
    7.         return;
    8.         else
    9.     number ++;
    10.     bt1 = true;
    11.     var lobjetct : GameObject = GameObject.FindWithTag("machine");
    12.     lobject.animation.Play ("anim1");
    Tried this too:

    Code (csharp):
    1.  var bt1 = false;
    2. var bt2 = false;
    3. var bt3 = false;
    4.  
    5.     if (hit.gameObject.tag == "button"  bt1 == false) {
    6.     number ++;
    7.     bt1 = true;
    8.     var lobjetct : GameObject = GameObject.FindWithTag("machine");
    9.     lobject.animation.Play ("anim1");