- Home /
Hold Down Button
I'm making a FNaF game, and I am making my own 'puppet' how could I make a button that'll slowly go down and then when I hold the button it'll go up, and if it reaches nothing (i'll make something happen' Can someone help me with this? I have found no tutorials for this.
Answer by Defetysta · Feb 19, 2019 at 12:32 PM
You can make something like:
float value = 1;
Update()
{
if(ButtonNotBeingPressed() )
value -= Time.deltaTime/10;
//it will take 10 seconds for the value to reach 0
else if(value < 1)
value+= Time.deltaTime / 3;
// 3 seconds to reach value 1
}
Where would I put the code that I want it do to when it reaches 0?
float value = 1;
Update()
{
if(ButtonNotBeingPressed() )
{
value -= Time.deltaTime/10;
if(value < 0)
{
//do your code here
}
//it will take 10 seconds for the value to reach 0
}
else if(value < 1)
value+= Time.deltaTime / 3;
// 3 seconds to reach value 1
}
It gives an error for the term, ButtonNotBeingPressed. Can you elaborate?
Your answer
Follow this Question
Related Questions
[4.6 b20] How to make a hold button for the new UI 4 Answers
Buttons become invisible when changing color (on Button or on Image) in script -1 Answers
Unity 5.0.2f1 UI Button OnClick Function 6 Answers
Using listeners to complete code errors 0 Answers
Is the 'highlighted state' the same as the 'selected state'? 2 Answers