- Home /
Character controller Joystick issues.
Hi, I was using a custom script for my character and physics, but decided to start over and build my own.
The other script was not using a character controller, but now I am. I'm having issues getting the physics and input settings to behave correctly on my x360 PC controller I've been using. When I move the character, then let go of the joystick, the character stops moving instantly which is very unrealistic. Altering the input settings such as gravity/sensitivity have undesired effects (such as permanent sliding or making the character violently fly off in one direction). Using the keyboard works just fine, I can set the values to behave correctly. I don't think my x360 controller is to blame as it was working well before.
I've been putting this issue off for awhile... any ideas what may be wrong here? Thanks!
Answer by Visual Programmer · Sep 28, 2013 at 01:22 AM
I'm guessing somewhere in your script you have:
if(Input.GetAxis("Horizontal") != 0){
movement.x = Input.GetAxis("Horizontal") * speed;
}else{
movement.x = 0;
}
You'll want it to read more like so:
if(Input.GetAxis("Horizontal") != 0){
movement.x = Input.GetAxis("Horizontal") * speed;
}else{
if(movement.x > 0.1){
movement.x *= drag;
}else{
movement.x = 0;
}
}
Your answer
Follow this Question
Related Questions
How to get input from wheel(car direction) joystick? 1 Answer
Is there a way to create a floating JoyStick using the On-Screen Stick component? 0 Answers
How can I control cursor with joystick 4 Answers
Joystick Zone + Screen-swipe touch input clash. Solution??? 1 Answer
Using Right Joystick to Select Weapon in Weapon Wheel 1 Answer