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 /
avatar image
0
Question by swanne · Oct 22, 2017 at 09:11 PM · player movementtransform.translateinput.getaxis

Player character moves without controller input

Hi. Very grateful for any insight anyone may be able to provide.

I am creating a space fighter type game. The controller input is a standard joystick and it works fine although quite often the player game object floats up on its own, without controller input.

The code I have used is below:

  void FixedUpdate ()
     {
         
         float moveHorizontal = Input.GetAxis("LeftThumbX");
         float moveVertical = Input.GetAxis("LeftThumbY");
         float boost = Input.GetAxis("RightTrigger");
                            
         Vector3 movement = new Vector3(moveHorizontal, moveVertical, 0.0f);
                                      
         //This is a boost and brake function
         if (boost > 0)
         {
             movement *= boostMovementSpeed;
             body.velocity = movement;
             
         }
         else if(boost < 0)
         {
             movement *= brakeMovementSpeed;
             body.velocity = movement;
         }
         else
         {
             movement *= moveSpeed;
             body.velocity = movement;            
         }

Comment
Add comment · Show 2
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 TanselAltinel · Oct 24, 2017 at 08:43 AM 0
Share

Do you have deadzone for your analog thumbs? Debug moveHorizontal and moveVertical values.

avatar image TreyH · Jan 08, 2018 at 09:52 PM 0
Share

From the docs on Rigidbody.velocity:


In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour. Don't set the velocity of an object every physics step, this will lead to unrealistic physics simulation.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by swanne · Oct 24, 2017 at 09:47 AM

Hi @TanselAltinel thank you for taking the time to comment.

Yes, I have dead zones setup for the controller and have used Debug.Log to measure the input. Both horizontal and vertical are at zero.

I'm still very confused

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 TanselAltinel · Oct 24, 2017 at 10:39 AM 0
Share

Well then, I think it may have to do with vector cross product where you are multiplying movement with boost$$anonymous$$ovementSpeed and brake$$anonymous$$ovementSpeed, can you debug the latest velocity in each case of if else? Because I believe that's the part setting it to a go ins$$anonymous$$d of horizontal/vertical inputs.

avatar image
0

Answer by m00per · Jan 08, 2018 at 09:01 PM

I had a similar problem and it took me a while to realise that I still had vJoy (Joystick simulator) installed and removing it fixed it for me.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

72 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

Related Questions

C# Player Movement help? 2 Answers

What script should I write for RotationHelper for my code to work? 0 Answers

Translating Player Movement and Clipping Through Walls 2 Answers

How to stop input after hitting a certain velocity 1 Answer

Quaternion rotation triggers change in Texture 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