'joystick getting stuck if you press 2 joysticks at the same time
I'm developing a game in which there are 2 joysticks 1 for movement 2 for shooting, so joystick 2 starts to stick if you hold down 2 joysticks at the same time. I tried to fix it by changing speed of each joystick but nothing happened its still here. I dont know what to do so Here is the code
namespace GeekGame.Input{
public class JoystickFire : MonoBehaviour,IPointerDownHandler,IPointerUpHandler
{
public static JoystickFire instance=null;
private bool _fire=false;
public bool Fire{
get{return _fire;}
}
void Awake(){
if(instance!=null){
Destroy(this.gameObject);
} else {
instance=this;
}
}
public void OnPointerDown(PointerEventData data){
_fire=true;
}
public void OnPointerUp(PointerEventData data){
_fire=false;
}
}
}
Solution 1:[1]
It's probably this line:
public static JoystickFire instance=null;
Any time you declare something static, it means "there will be only 1". Which is probably not what you want when there are 2 joysticks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Neil |
