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
2
Question by bpcortijo · Jul 15, 2021 at 09:35 PM · inputaction

How to bind multiple actions at once with unity's new input system?

I'm doing a game that has multiple action maps, some of the inputs are the same between these action maps like sprinting. I understand how to bind sprint on one action map but how do I bind it on the other without asking the player to press the button again?

 using UnityEngine.InputSystem;

 InputActionRebindingExtensions.RebindingOperation rebindingOp;
 void StartRebind ()
 {
     rebindingOp = actionMapBinding.action.PerformInteractiveRebinding()
         .WithControlsExcluding("Mouse")
         .WithCancelingThrough("Touchpad")
         .WithCancelingThrough("Escape")
         .WithCancelingThrough("Select")
         .WithCancelingThrough("Start")
         .OnMatchWaitForAnother(.1f)
         .OnComplete(operation => RebindComplete())
         .Start();
 }
 void RebindComplete ()
 {
     int bindingIndex = actionMapBinding.action.GetBindingIndexForControl(actionMapBinding.action.controls[0]);
 
     if (HasDuplicateBindings(actionMapBinding.action, bindingIndex, false))
     {
         Debug.Log("Binding already taken");
         actionMapBinding.action.RemoveBindingOverride(bindingIndex);
         rebindingOp.Dispose();
         StartRebind();
         return;
     }
 
     inputs[selection].GetComponentInChildren<TMP_Text>().text = InputControlPath.ToHumanReadableString(
         actionMapBindings.action.bindings[bindingIndex].effectivePath ,
         InputControlPath.HumanReadableStringOptions.OmitDevice
     );
 }


Comment
Add comment · Show 1
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 oscarAbraham · Jul 16, 2021 at 04:52 AM 0
Share

First, let me say that I've not tried this, but it seems like a good UX idea for some cases. I'd normally use only one map for all those cases, set a different binding group for different controls that are usable in different cases, and deactivate/activate control groups with a binding mask according to the current use case. Or I'd just make users bind actions twice if they seem different enough. But your idea seems cleaner for a lot of uses. Have you tried using ApplyBindingOverride to copy the binding from the first action to a second one on RebindComplete?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kikchitov · Apr 01 at 09:31 AM

 using UnityEngine.InputSystem;
 
 void OnRebindingComplete (
     InputActionRebindingExtensions.RebindingOperation operation ,
     int bindingIndex ,
     params InputAction[] duplicates
 )
 {
     foreach( var duplicate in duplicates )
         duplicate.ApplyBindingOverride( bindingIndex , operation.selectedControl.path );
 }


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

156 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

Related Questions

New Input System 'Started' and 'Performed' actions fire at the same time? 1 Answer

SteamVR Input window not loading properly 0 Answers

How to consume input when automatically switching control schemes through a Player Input Component 0 Answers

How can I detect when a binding is pressed in the new input system? 0 Answers

XR controller - New Input System - .perform x .canceled - small float values x dead zone 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