0
\$\begingroup\$

So I just completed the first "Roll-a-ball" tutorial, but when I run the build, the game ball races to the Upper-Left corner even when I don't press any buttons.

I did the obvious stuff (reboot, build again...) but it still does it for the PC stand-alone build, and not when I play directly from Unity.

My code doesn't seem to be different from the tutorial (see link above). Here's the input handling code inside of the "PlayerController.cs":

    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

	rb.AddForce (movement * speed);
    }

Then I added statements to print the Horizontal and Vertical. When inside the IDE and I play it, they're zero, and when I press an arrow key, they move from 0 to 1 floating point in about a second. In the built stand-alone, Horiz is -1, Vert is 1.

void SetCountText ()
{
    countText.text = 
        "Count: " + count.ToString () + "\n" + 
        "Horizontal: " + Input.GetAxis("Horizontal").ToString() + "\n" +
        "Vertical:" + Input.GetAxis("Vertical").ToString()
        ;
    if (count >= 12) {
        winText.text = "YOU WIN!!";
    }
}

Ball in UL corner

\$\endgroup\$
4
  • \$\begingroup\$ Take a look at your input handling code, and determine what input is being read when the ball is moving this way. That should help narrow down whether the problem is bad input coming in, or something further down the pipe in your control scripts. \$\endgroup\$
    – DMGregory
    Sep 16, 2017 at 20:53
  • \$\begingroup\$ The next part of my question was asking you to determine whether those Input.GetAxis(...) calls are returning strange values in the built game, and what those values are. \$\endgroup\$
    – DMGregory
    Sep 16, 2017 at 22:55
  • \$\begingroup\$ Okay, but the problem doesn't happen in your IDE, right? It's in the built game. So that's where you need to examine the values. \$\endgroup\$
    – DMGregory
    Sep 17, 2017 at 1:07
  • \$\begingroup\$ So I dove down the rabbit hole of "how the heck do I know where the signal is coming from" - it looks like the answer is that I can't without some 3rd party help? feedback.unity3d.com/suggestions/… \$\endgroup\$
    – Baronz
    Sep 17, 2017 at 1:18

1 Answer 1

1
\$\begingroup\$

So after a lot of digging and trying random things, I found out that it's my 3DMouse driver. Even when I didn't have the spacenavigator plugged in, there was something that Unity was seeing.

enter image description here

I fixed the issue in settings by unchecking all of the axis.

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .