- Home /
Question by
byteblorg · Oct 06, 2017 at 04:07 AM ·
scripting problem
my vehicle doesn't brake completely when going forward
Here's my code for a simple usercontrol input for a vehicle that has fwd,neu,rvs gears.
When i step the brake pedal while reversing, great. it slows down and stops completely.
But for the forward movement;it slows down to 0; then the vehicle starts reversing! Accelerator pedal on the Y axis +. Brake on the Y axis -. How do i fix this? Thanks!
if ((GameObject.Find ("handbrakei").GetComponent<handbrake> ().release) && (GameObject.Find ("movegeari").GetComponent<movegear> ().forward))
{
// pass the forward to the car!
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
float handbrake = Input.GetAxis ("Jump");
m_Car.Move (h, v, v, handbrake);
//Debug.Log (Input.GetAxis ("Accelerate"));
}
if ((GameObject.Find ("handbrakei").GetComponent<handbrake> ().release) && (GameObject.Find ("movegeari").GetComponent<movegear> ().reverse))
{
// pass the reverse to the car!
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
float handbrake = Input.GetAxis ("Jump");
m_Car.Move (h, -v, -v, handbrake);
}
if (Input.GetAxis ("Vertical") < 0.0f && (GameObject.Find ("movegeari").GetComponent<movegear> ().reverse))
{
float h = Input.GetAxis ("Horizontal");
float v = 1;
float handbrake = 1;
m_Car.Move (h, 0, 1, handbrake);
}
}
Comment