- Home /
Car driving backwards with triggers
In the Input manager, I made a "Triggers" input that works with my PS4 controller with the 5th axis. The only problem is that when no trigger is pressed, it does not return to 0. It returns to -1 which makes the car drive backwards. This is what happens: R2 = 1 L2 = -1 Nothing Pressed = -1
How can I get "Nothing pressed" to return to 0?
Answer by getyour411 · Jan 12, 2014 at 07:51 PM
Since you don't show code, how about
If(NothingPressed == -1)
NothingPressed = 0;
Code for the axis's for my car:
BackLeftWheel.motorTorque = -EngineTorque * GearRatio[CurrentGear] * DifferentialRatio * Input.GetAxis("Triggers") *100;
BackRightWheel.motorTorque = -EngineTorque * GearRatio[CurrentGear] * DifferentialRatio * Input.GetAxis("Triggers") *100;
var speedFactor = rigidbody.velocity.magnitude/highestspeed;
var currentsteerangle = $$anonymous$$athf.Lerp(lowspeedsteerangle,highspeedsteerangle,speedFactor);
currentsteerangle *= Input.GetAxis("Horizontal");
Here is the input manager settings for "Triggers":
Name------------------Triggers Negative Button-------joystick button 4 Positive Button-------joystick button 5 Gravity---------------0 Dead------------------0 Sensitivity-----------1 Snap------------------Unchecked Invert----------------Unchecked Axis------------------5th axis (Joysticks) Joy Num---------------Get $$anonymous$$otion from all joysticks
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Targetting script bug. (Javascript) 0 Answers
Controller/keybord inputs delay/not responding 1 Answer
Parsing Error CS8025 1 Answer