|
I use a joystick to move around. When I don't touch my joystick, my character still moves. Is there a way to stop this?
(comments are locked)
|
|
Input.GetAxis can return small values when the joystick (or other game controller) is slightly uncalibrated. Due to this, you should never compare Input.GetAxis to zero, like this: Since Input.GetAxis returns a float value between -1 and 1, the best approach is to use something like this: The value returned by GetAxis is compared to a "safety margin", so small values will not move the character. If this doesn't solve your problem, please post the script where you read the game controller. I used the Input Manager of unity and set the Dead to 0.1, but it doesn't work as expected.
Jun 14 '11 at 12:13 PM
Aldwoni
Post the script where you read Input.GetAxis and move your character.
Jun 14 '11 at 12:34 PM
aldonaletto
1- There's something wrong with the line below: if(transform.localPosition.y + verticaal =bewegingsgrensrechts) Is the = supposed to be >= or <=? if (Mathf.Abs(horizontaal)<0.01) horizontaal = 0; 3- The rigidbody will keep its velocity until friction consumes it; set the Drag rigidbody parameter to 0.5 or something alike to stop the object after a decent time.
Jun 14 '11 at 02:01 PM
aldonaletto
Jun 14 '11 at 02:17 PM
Aldwoni
Well, let's go back to the beggining:
Jun 14 '11 at 05:09 PM
aldonaletto
(comments are locked)
|
|
It is likely that you are not setting a dead zone on your controller. What you need to do is set a small area on the stick that does not respond to any input. To do this when you do Input.GetAxis you need to do something like: You now have a dead zone between -0.1 and 0.1 on that particular axis. This issue is caused due to controller stick not sitting exactly at 0.0 even when noone is using them. I used the Input Manager of unity and set the Dead to 0.1, but it doesn't work as expected.
Jun 14 '11 at 12:13 PM
Aldwoni
(comments are locked)
|

What does it mean: put my controller down?
I don't know how to say it in english. but I mean when you don't touch your controller. is that better?
Ok, you have a joystick or equivalent, and your character moves even when the joystick is in the null position, is it correct? Your character moves very slowly in this case? Are you using Input.GetAxis to read the joystick?
If you talk about input keys(keyboard) such as w,a,s,d. Then you are using Input feature such as Input.GetKeyDown. But if you release the button, it still moves, then it is about how it is programmed, it shouldnt generally moves according to the tutorials of Unity and traditional programming as soon as it is a rigidbody with force, you need to show some code
I use Input.GetAxis on my joystick