Hi i need to have a move in which the player needs to hold down a key and then press another key to activate a move.
The move stays active while the button is held down.
Button that needs to be held is called “hold”
Button that needs to be pressed is called “press”
if(Input.GetButton("held") Input.GetButtonUp("press"))
{
//stuff
}
else if(!Input.GetButton("hold"))
{
//can't do stuff
}
this doesn’t work though so i tried this
if(Input.GetButton("held"))
{
playerControl = false;
Debug.Log("huh?");
}
else
{
playerControl = true;
Debug.Log("wuh?");
}
And it prints
wuh?
huh?
wuh?
huh?
…
in the debug menu while i’m holding down the button.
What exactly am i doing wrong?
Well, I just tested literally the copy/paste code and I didn’t even get the same results(expected as it looks A-OK). I’m not sure what your problem is, but I would try using another key other than “held” first. Try “Fire1”(Preconfigured) and see if you still get the same results. Also, another good test, put in a time stamp to see if they are called on the same frame, or alternating frames.
if(Input.GetButton("held"))
{
playerControl = false;
Debug.Log("huh - " + Time.time);
}
else
{
playerControl = true;
Debug.Log("wuh - " + Time.time);
}
That’s also beneficial. Let me know what you find out and I’ll try to help further, otherwise, maybe someone else knows whats up :P, (I’m just try to debug it lol).
I got it sorted out thanks for your help it was due to some other code in my script futher along thanks alot!