- Home /
Too much mousedown because of laptop touchpad?
Hello,
I have a script on a button that starts something to rotate on pointer down and stops the rotation on pointer up. This is triggered by an event trigger. It sets a bool to true if pointerdown and false on pointerup.
Now this works all fine except if i go on my laptop and try it out i can get too many pointersdown from my laptop touchpad? because now it keeps rotating sometimes and can only be stopped by pressing the button again, but if i release it goes again.
So is there a way to prevent this? I tried waitforseconds function and that works but it still happends.
Thi is my code:
public static bool bpressedleft = false; public static bool bpressedright = false; public int nmrotateSpeed = 1; public static float lockPos = 0; public static float nmstandvanazi = 0;
public void fTurnLeft()
{
bpressedleft = !bpressedleft;
}
public void fTurnLeftPointerup()
{
bpressedleft = !bpressedleft;
}
public void fTurnRight()
{
bpressedright = !bpressedright;
}
public void fTurnRightPointerup()
{
bpressedright = !bpressedright;
}
void Update () {
nmstandvanazi = transform.localRotation.eulerAngles.y;
if (bpressedleft)
{
transform.Rotate(-Vector3.up * nmrotateSpeed);
}
if (bpressedright)
{
transform.Rotate(Vector3.up * nmrotateSpeed);
}
}
btw i formatted my code with the code button, why doesnt it work properly?
Your answer