- Home /
analog joystick
hi, i want to make a character dash by using a analog joystick, like move two time analog and then the character dash. how supposed i created or can it be done or cannot.
Answer by hectorux · Nov 12, 2018 at 12:05 AM
It can, that make me a headache when i tryed first time, you could get the Input.GetAxis("Horizontal") which in the input editor holds "a", "d", "leftArrow", "rightArrow", "all horizontal left joystic direction from all joystic". with this, you can make your own input, and set something like this:
if(Input.getAxis("Horizontal")>0.5f && !stoped){
stoped=true;
if(timebetweenInputs>Time.time){
DashFunction();
}
timeBetweenInputs=Time.time+timeToWait;
}
if(Input.getAxis("Horizontal")<0.5f){
stoped=false;
}
@hectorux how about double horizontal? , i mean like double move analog joystick
Unity doesn't have any input for that, you could check if the joystick whnt to 0 or was negative between a certain interval, and if then it becomes more than 0, then it has make a double move. The problem is that xbox controller works with values between -1 to 1, and playstation works with the delta move of the joystick, it gives +0.01 or -0.0856; this makes complicated to make a complete system, because the play will give you changes as deltas, but the xbox will give you the current value of the input
@hectorux i mean like this, like button we press two time to dash so i want to change the way it and be like move analog joystick to the left or right two time to dash. it is possible to do it.