GetKeyDown || Up doesnt work,my GetKeyUp function doesnt work in unity

Normally when I press the plus button it has to get bigger and stay like that until i press it for the second time. But when I press it I have to hold it so it stays bigger and when i let go it returns to beginner state. thanks in advance

public float scaleAmount = 3.0f;
public Vector3 OriginalScale = Vector3.zero;

void Awake () {
    OriginalScale = this.transform.localScale;
}
void  Update  ()
{
    if (Input.GetKeyDown(KeyCode.KeypadPlus))
    {
        this.transform.localScale = Vector3.one * scaleAmount;
    }

    else if (Input.GetKeyUp(KeyCode.KeypadPlus))
    {
        this.transform.localScale = OriginalScale;
    }
}

}

Your code does exactly what it is supposed to do. When you press down your plus button it will scale it up, and when you let the plus button go it will return to normal state. If you want the button to toggle the scaling on subsequent presses, you need to use a flag.

bool scaled = false;

void  Update  ()
 {
     if (Input.GetKeyDown(KeyCode.KeypadPlus))
     {
		if (scaled)
		{
			this.transform.localScale = OriginalScale;
			scaled = false;
		}
		else
		{
			this.transform.localScale = Vector3.one * scaleAmount;
			scaled = true;
		}
     }
 }

ohh, okay, I thought it wasnt meant to be like that. thanks :slight_smile: