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:
var rotationSpeed = 100;
function Update ()
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
Thanks in advance.
(copied from comments)
hmm… open your input manager:
try changing the name of the SECOND “Horizontal” to something else… (the one that says joystick) then test again (just a longshot)
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.