Search Unity

Press Key to Appear, Release key to disappear.

Discussion in 'Scripting' started by Blackout_99, Jan 28, 2015.

  1. Blackout_99

    Blackout_99

    Joined:
    Jul 10, 2013
    Posts:
    13
    I've written a script to bring up arms but the come up when i press and go away when i press again. I want to be able to press to bring them up and release to make them go away. Please help

    #pragmastrict

    functionStart () {
    this.renderer.enabled = false;
    }

    functionUpdate () {
    if(Input.GetKeyDown("q"))
    {
    if(this.renderer.enabled == false)
    {
    this.renderer.enabled =true;
    }

    else
    {
    this.renderer.enabled = false;
    }
    }
    }
     
  2. Defero

    Defero

    Joined:
    Jul 9, 2012
    Posts:
    200
    Kiwasi likes this.
  3. Blackout_99

    Blackout_99

    Joined:
    Jul 10, 2013
    Posts:
    13