Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
This question was closed Nov 18, 2015 at 06:13 PM by Razputin for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Razputin · Nov 18, 2015 at 04:07 PM · controlleraxisjoysticksupportstick

Moving using controller stick question

Trying to make it so -1 on the axis moves the player left and 1 moves the player right but my script doesnt appear to do anything. I was never able to figure out how to properly do controller support for my last game but I really want to include it this time because people seemed to really want it. I can do the buttons easy enough but I don't understand the axis's. What am I doing wrong?

              if(Input.GetButton("Horizontal"))
              {
                  if(Input.GetAxisRaw("Horizontal") < 0)
                  {
                      Debug.Log("Left");
                      vel.x = -walkSpeed;
                  }
                  if(Input.GetAxisRaw("Horizontal") > 0)
                  {
                      Debug.Log("Right");
                      vel.x = walkSpeed;
                  }
              }else
              {
                  vel.x = 0;
              }
 

Maybe my project settings are wrong?

Name : Horizontal Neg Button: Left Pos Button: Right Alt Neg: A Alt Pos: D Grav: 3 Dead: 0.001 Sens : 3 Snap : Yes Invert : No Type : Key or Mouse Button Axis : x axis Joy Num : Get Motion From all

Please Note : Moving the joystick does not trigger the Debug.Log

Comment
Add comment · Show 1
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
avatar image Razputin · Nov 18, 2015 at 05:38 PM -1
Share

Bumping thread

1 Reply

  • Sort: 
avatar image
0

Answer by Jessespike · Nov 18, 2015 at 04:17 PM

Input.GetAxisRaw returns a number between -1 and 1, as mentioned in the documentation. Replace your code with this one line:

 vel.x = walkSpeed * Input.GetAxisRaw("Horizontal") * Time.deltaTime;

Comment
Add comment · Show 1 · Share
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
avatar image Razputin · Nov 18, 2015 at 04:25 PM 0
Share

The problem isn't that I don't move. The problem is that moving the joystick does nothing. Doesn't even activate the debug.log

Follow this Question

Answers Answers and Comments

31 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

Related Questions

How to know if finger is on joystick if it is at horizontal & vertical zero 0 Answers

Controller Joystick Hold Delay Logic? 1 Answer

How to zero out the value of the joystick 0 Answers

Problems with joystick / controller axes being 1/-1 "way too often" 1 Answer

How do I create joystick controls with two fixed speeds? (3D) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges