- Home /
Question by
unity_10datmad · Jan 22, 2020 at 05:59 PM ·
getaxis
GetInput and getaxis
Hi everyone,
I have a car with AI script, and I need to activate AI with pressing button =6 on Logitech steering wheel ,and deactivate AI by pressing button=7 on the steering wheel or entering horizontal or vertical inputs. When pressing button 6 it activates AI, other it also deactivates with other button 7 or horizontal or vertical inputs. The issue here is that it does not re-activate the AI by pressing button 6.
The script is here. Any help is much appreciated.
private void Update()
{
if (Input.GetKey("joystick " + 1 + " button " + 6))
{
myCar.GetComponent<PlayerCar_Script>().enabled = false;
myCar.GetComponent<AICar_Script>().enabled = true;
Debug.Log("Enabled AI on my car..");
activateAI = true;
}
if (Input.GetKey("joystick " + 1 + " button " + 7))
{
myCar.GetComponent<PlayerCar_Script>().enabled = true;
myCar.GetComponent<AICar_Script>().enabled = false;
Debug.Log("Enabled AI on my car..");
}
if (System.Math.Abs(Input.GetAxis("Horizontal")) > 0 || System.Math.Abs(Input.GetAxis("Vertical")) > 0)
{
activateAI = false;
myCar.GetComponent<PlayerCar_Script>().enabled = true;
myCar.GetComponent<AICar_Script>().enabled = false;
Debug.Log("Disabled AI on my car..");
}
}
Comment