• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
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
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

118 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GetAxis for MouseX for web player. 0 Answers

How to put limits in Z? 0 Answers

Detecting cross platform input? 0 Answers

Mouse event build up? 0 Answers

Animtion looping if joystick is held 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges