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 LunaArgenteus · Apr 16, 2013 at 03:03 AM · inputscenejoystickapplication.loadlevel

Missed Input Events with Joystick

I'm working on a game with multiple scenes, and I'm having trouble with input events for my joysticks (I'm using PS3 controllers).

I'm using button presses to change scenes, but when the scene changes, the next button press of the button used to change the scene does not register, but works fine for the rest of the scene.

So, for example, if I'm at the Start menu, I press "Start" to move to change scenes and move to another menu (say, save data select). Until I press "Start" again, Input.GetButton, Input.GetButtonDown, and Input.GetButtonUp functions WILL NOT RETURN TRUE. So if I get in game and want to pause, I'll press start, and it will do nothing - press start again and it brings up the menu.

I'm fairly certain this is a bug with Unity, as I've managed to recreate the error with relative ease in a separate project. I've tested with both keyboard and joystick input, but keyboard input does not seem to suffer from this problem. Here is the code in a sample project that can recreate the issue - the more complicated the scene is, the more likely it is to occur.

EDIT: Despite being fairly sure this is a bug with Unity, I want to see if anyone can help before I submit a bug report.

 using UnityEngine;
 using System.Collections;
 
 public class SceneChanger : MonoBehaviour {
     
     private int currentLevelIndex = 0;
     private const int LEVELS_IN_BUILD = 3;
     // Use this for initialization
     void Start () {
     
     }
     void OnGUI()
     {
         GUI.TextArea(new Rect(0,0, 100, 100), "Do stuff for test purposes");
     }
     // Update is called once per frame
     void Update () {
         if(Input.GetButtonDown("Button1"))
         {
             
             currentLevelIndex = 0;
             Application.LoadLevel(currentLevelIndex);
             Debug.Log("Scene 0");
         }
         if(Input.GetButtonDown("Button2"))
         {
             
             currentLevelIndex = 1;
             Application.LoadLevel(currentLevelIndex);
             Debug.Log("Scene 1");
         }
         if(Input.GetButtonDown("Button3"))
         {
             
             currentLevelIndex = 2;
             Application.LoadLevel(currentLevelIndex);
             Debug.Log("Scene 2");
         }
     }
 }


I'll also note that in my main project, I've tried putting calls to Input.ResetInputAxes() before and after loading the level (and by after I mean in the OnLevelWasLoaded function), but the result is the same.

For anyone who doesn't want to go through the trouble of setting up a new project with different scenes etc to test this, I've attached the sample project. Any help would be appreciated!

Also, just fyi, the input manager with this project is set up to take input from the Cross, Circle, and Start buttons on a Ps3 controller. I'm running Unity on my mac, so if you're using windows and the DS3 tool, it might register differently and you might need to adjust the input settings.

Sample Project

testinputwithscenechanges.zip (200.5 kB)
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 LunaArgenteus · Apr 16, 2013 at 04:12 AM 0
Share

Something else interesting to note - I was fooling around with the project, and holding down any of the $$anonymous$$EYBOARD keys mapped to Button 1, 2, or 3 causes the level to be reloaded repeatedly (and as you can see, I'm using GetButtonDown(), not GetButton()) . . . hmmm

avatar image LunaArgenteus · Apr 26, 2013 at 11:43 AM 0
Share

After doing some more tests, if I put my level loading in a coroutine that waits until the end of the current frame before executing, then the problem di$$anonymous$$ishes. It seems like if I press and release the button very quickly, it still occurs, but if I hold the button down and release after the new scene is done loading, I don't get the bug.

0 Replies

· Add your reply
  • Sort: 

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

11 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

Related Questions

scripting joystick input on javascript 1 Answer

Steering Wheel / joystick GetAxis trouble 0 Answers

Application.Loadlevel taking time to load scene 1 Answer

Unity 5.3 How to load current level 3 Answers

D-Pad as Button instead of Axis 3 Answers


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