Right now what I have set up is an event trigger on a UI Button that when the user presses and holds down the button it will hold the character in place and when the user lets go of the button the character is able to move again. What I am trying to do is have it so after a certain amount of time has passed of the user holding down the button the character will just start moving. No matter how long the user holds down the button the character will start moving after a certain amount of time has passed. Here is the code that I have right now. All that happens right now is when the user holds down the button the character stops moving but if the user keeps holding down the button the character will not move. I am unable to get it so that the character will start moving after a certain amount of time.
if (_sliding && timer >= 0.2)
rb.constraints = RigidbodyConstraints.FreezePositionY;
else if (!_sliding || timer >= 0.4)
rb.constraints &= ~RigidbodyConstraints.FreezePositionY;
rb.constraints = RigidbodyConstraints.FreezePositionX;
The timer I have running in a different part of the code. The timer only runs when the user presses and holds down the button.
If anybody has any suggestions that would be great!