Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Sir__Walter · Dec 14, 2013 at 07:06 AM · ballroll

Controllable ball rolling away by itself

I'm new to unity and following this tutorial on making a basic ball game. whenever I start the game, the ball automatically rolls to the left as if I'm holding the 'A' key. I can make roll back to the right by holding 'D', but as soon as I let go of 'D' it rolls back the left again.

this is the code I'm using to control the ball:

 #pragma strict
 
 var rotationSpeed = 100;
 
 function Update () 
 {
     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
     rotation *= Time.deltaTime;
     rigidbody.AddRelativeTorque (Vector3.back * rotation);
 }


Thanks in advance. :)

Comment
Add comment · Show 5
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 Seth-Bergman · Dec 14, 2013 at 07:31 AM 0
Share

start by adding this line to your Update:

 Debug.Log(Input.GetAxis ("Horizontal"));

then hit play, and see if the Debug log shows as 0 (while not pushing any buttons). Or does it ins$$anonymous$$d show a positive number?

avatar image Sir__Walter · Dec 14, 2013 at 08:04 AM 0
Share

Thanks for the reply, the debug shows a value of -1, and when I hold D its changes to a value of 1, let go of D, it goes back to -1. Any ideas on what might be causing this and how to fix it? Thanks.

avatar image Seth-Bergman · Dec 14, 2013 at 08:32 AM 0
Share

hmm.. open your input manager:

http://docs.unity3d.com/Documentation/Components/class-Input$$anonymous$$anager.html

try changing the name of the SECOND "Horizontal" to something else.. (the one that says joystick) then test again (just a longshot)

avatar image Sir__Walter · Dec 14, 2013 at 08:41 AM 0
Share

Thankyou!! worked just fine when I renamed it to Hoizontal2. I have a flight stick and a controller connected to my PC, it must have been getting the value from one of them? Once again, thanks for helping me out! :)

avatar image Seth-Bergman · Dec 14, 2013 at 08:47 AM 0
Share

yep, that's exactly what it was. Glad to help!

I'm going to post the solution as an answer, please accept it so others will know..

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Seth-Bergman · Dec 14, 2013 at 08:52 AM

(copied from comments)

hmm.. open your input manager:

http://docs.unity3d.com/Documentation/Components/class-InputManager.html

try changing the name of the SECOND "Horizontal" to something else.. (the one that says joystick) then test again (just a longshot)

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
avatar image
0

Answer by TP3 · Dec 10, 2015 at 05:11 PM

I'm a beginner, but I also had a ball that was moving by itself, even if the player controller script was disabled/deleted. There's probably several things that could've gone wrong for you or I but for me the issue was the 'Walls'.

I assume as they are quick and rough cubes that are all overlapping/touching the 'Ground' was getting somehow shook very slightly in weird ways which could not be seen by the eye. By lifting the 'Walls' in the hierarchy so they were not touching the 'Ground' the issue went away. I'm sure in a real game walls wouldn't be created from 4 duplicated cubes and would be perfectly positioned, so not too big of an issue but i'm glad I found the culprit eventually.

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

18 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

Related Questions

How to roll the ball? 1 Answer

How to make a ball that can roll? 2 Answers

Rolling ball Text error. Removes itself when played 0 Answers

Making a ball roll and keeping the axis? 2 Answers

Problem with joystick movement 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