-1
\$\begingroup\$

So basically, when my scene in Unity changes and I'm holding down, say, Right or Left, when the scene resets, my player (and Unity) doesn't even recognize that I'm still holding that button, until I lift my finger and put it back.

Any thoughts?

Sorry for any broken English or anything, I'm running off two hours of sleep.

\$\endgroup\$
5
\$\begingroup\$

Using this in my dataHolder that persists between scenes I continuously got space key was pressed logged in the console.

 void Update () {
        if (Input.GetKey("space"))
            print("space key was pressed");
    }

The trick here is to make sure the instance of the script that handles button presses persists between scene loads.

\$\endgroup\$
  • \$\begingroup\$ Ah, why didn't I think of that? Thank you! \$\endgroup\$ – GMR516 Jun 2 '16 at 14:55
0
\$\begingroup\$

I'm making a racing game and I don't changes scenes, I just manipulate objects (instantiate / destroy, enable / disable).

\$\endgroup\$
  • \$\begingroup\$ good for you buddy. \$\endgroup\$ – Uri Popov Jun 3 '16 at 6:25
  • \$\begingroup\$ I meant it as a suggestion. \$\endgroup\$ – NaBUru38 Jun 15 '16 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.