Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
1
Question by LexGear · Jun 28, 2020 at 01:55 AM · input3dtriggerscontrollersinput manager

Input System Button Triggers Multiple Times

Hi guys. So I've been playing around with the new Input System and things are starting to get a little frustrating. My issue is button pushes are firing multiple times. I've tried multiple settings with the type of action (eg Button, Pass Through etc), and Interactions being set to press only, or release or whatever, doesn't seem to matter. It'll either fire 2 times or 4 times depending on the settings.


I've got multiple controllers here for testing and as if that wasn't confusing enough, if a second or more player joins in, their button pushes trigger only once. It's always only player one's buttons who trigger multiple times. Does anyone know how to fix this?


Looks like I'm not the only one, looking at this forum thread.


Here is my very simple, basic test code just for reference.

 public void GetInteractValues( InputAction.CallbackContext value )
     {
         if ( value.started )
             print("foo");
     }


Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by aDaxxas · Aug 07, 2020 at 09:34 AM

My solution was to add an if statement like this :

 public void PickupObject(InputAction.CallbackContext context)
 {
         if (context.performed)
         {
             Debug.Log("PERFORMED");
         }
 }

I think that there is multiple context (started, canceled, performed...) and by default it's reacting to every state

Comment
Add comment · Show 2 · 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 LexGear · Aug 16, 2020 at 02:32 AM 0
Share

No, this wasn't the solution. The "value.started" makes sure of that. It turns out the input system doesn't play well with prefab characters/players. Bug, if you ask me. I'll post the solution separately.

avatar image seriphis LexGear · Jan 22 at 10:57 PM 0
Share

Commenting to this as this was one of the first hits on Google so i think its worthwhile dropping on here...

I believe you may have had 2 issues, and for the general case this may well be the solution.

The input system ABSOLUTELY triggers multiple event triggers per 'button' press for each of the "Phases" within its context.

E.g:

 EventSystem is running OnReturned in context:{ action=Player/OnReturn[/Keyboard/enter] **phase=Started** time=8.6282363999926 control=Key:/Keyboard/enter value=1 interaction=UnityEngine.InputSystem.Interactions.PressInteraction }
     
 EventSystem is running OnReturned in context:{ action=Player/OnReturn[/Keyboard/enter] **phase=Performed** time=8.6282363999926 control=Key:/Keyboard/enter value=1 interaction=UnityEngine.InputSystem.Interactions.PressInteraction }
     
 EventSystem is running OnReturned in context:{ action=Player/OnReturn[/Keyboard/enter] **phase=Canceled** time=8.74305079999613 control=Key:/Keyboard/enter value= interaction=UnityEngine.InputSystem.Interactions.PressInteraction }

(**'s added to draw attention to the phase)

I was unable to replicate your other answer of having a prefab not in the scene triggering a second instance, or generating an input system by pre-fab generating a second instance... I could only guess that it may have been as a result of an 'addlistener' duplicating. Alternatively, it was a bug that has since been fixed in 2020.3.24f1.

avatar image
4

Answer by LexGear · Aug 16, 2020 at 02:35 AM

Answer found after months of searching on another forum. Prefab triggers a second instance. This is obviously a bug. But here is how you make sure it doesn't fire twice. Check the scene for the gameobject in question before proceeding.

Checking for gameObject.scene.IsValid() when processing the action callback appears to work around the issue, but a proper fix would certainly be preferred.

Comment
Add comment · Show 1 · 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

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

Related Questions

Unity's Explorer 3D Game Kit on Mobile! 2 Answers

hello do any of you guys know how to make a 2 player Dpad game so me and my friend can play the game with a controller if so please tell me , i was having trouble and i was gonna ask if it is possible and if it is how do i do it 1 Answer

Unity Input.GetMouseButtonDown(0) not working 0 Answers

Multiple Joystick Input Trigger all Inputs 4 Answers

New input system bind meta quest 2 controller 0 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