Hello everyone,
I am using in FixedUpdate() function the Input.GetMouseButtonDown() method. I want my player to change the horizontal direction, so for this I have the following code:
if (Input.GetMouseButtonDown(0))
{
if(change == true)
{
rb.velocity = new Vector2(-12,rb.velocity.y);
change=!change;
}
else if(change == false)
{
change=!change;
rb.velocity = new Vector2(12,rb.velocity.y);
}
}
At the beginning, first 3-6 clicks, works fine (one click change direction, another click the other direction) but afterwards I have to press 2 or 3 times to change the actual direction.
What should I do to increase the accuracy, quality of changing directions?
Thank you very much for your patience and attention!