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 /
avatar image
0
Question by ddooms · Jan 02, 2021 at 05:33 PM · inputkeyinput managerkey pressedinputs

Multiple Key Input for new Input System Limited?

I've been using the new Input System to write a character controller. Currently, I have WASD for moving, shift for sprinting, and Q/E for strafing. I ran into an issue, however, that causes concern. When pressing more than 3 keys at a time, the input prioritizes the newest key pressed and forgets about the other one that is STILL pressed down. This is an insanely large issue, and I can't imagine this is intended. I can press W, A, and Sprint. Strafing causes A to drop off. If anyone knows a solution to this, I'd be grateful.

   private void Awake()
         {
             masterControls = new MasterControls();
 
             masterControls.Keyboard.Move.performed += c => OnMove(c);
             masterControls.Keyboard.Move.canceled += c => OnMove(c);
 
             masterControls.Keyboard.Sprint.performed += c => OnSprint(c);
             masterControls.Keyboard.Sprint.canceled += c => OnSprint(c);
 
             masterControls.Keyboard.Strafe.performed += c => OnStrafe(c);
             masterControls.Keyboard.Strafe.canceled += c => OnStrafe(c);
         }


Screenshot of control setup

2877e3fb4cc2fcbbdcb781ed47bda24c.png (24.6 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by toddisarockstar · Jan 03, 2021 at 07:24 AM

looking at this new small "feature" of "master controls".... seems like it would take longer to figure out the bug than to write the entire new "feature" yourself. Seems the friendly unity team will stop at nothing to prevent users from needing to write code. anyways, here is the same thing (cute and organized) that doesn't have bugs and also can expand to detect double clicks, tripple clicks, ups, downs, durations, blah ,blah,blah.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class move : MonoBehaviour
 {
 
     public delegate void voids(int i,int state);
     public class press {
         
         public bool state;
         public voids DoIt;
         public KeyCode key;
         public int Number;
         public press(KeyCode k, voids doit, int n) { DoIt = doit; key = k; Number = n; } 
     }
 
     public List<press> strokes;
     
     void Start()
     {
         strokes = new List<press>();
         strokes.Add(new press(KeyCode.W, yaxis, 1));
         strokes.Add(new press(KeyCode.S, yaxis, -1));
         strokes.Add(new press(KeyCode.A, yaxis, -1));
         strokes.Add(new press(KeyCode.D, yaxis, 1));
         strokes.Add(new press(KeyCode.Space, otherbuttons, 0));
         strokes.Add(new press(KeyCode.LeftShift, otherbuttons, 1));
         strokes.Add(new press(KeyCode.RightShift, otherbuttons, 1));
 
     }
 
     void Update()
     {
         int i = strokes.Count;
         while (i > 0) { i--; int state = 0;
             bool d = Input.GetKey(strokes[i].key);
             if (strokes[i].state != d) { state++; if (!d) { state++; } }
             if(d||state>0){strokes[i].DoIt(strokes[i].Number, state); }
             strokes[i].state = d;
     }}
 
 
 public void xaxis (int i,int state){ print("im moving " + i + " on x" ); }
 public void yaxis (int i,int state){ print("im moving " + i + " on y"); }
 public void otherbuttons(int i, int state) { print("pushing other button number" + i);
         if (state == 1) { print("button down"); }
         if (state == 2) { print("button up"); }
 
         } 
 
 
 }

 

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
avatar image ddooms · Jan 03, 2021 at 08:07 PM 0
Share

$$anonymous$$akes sense to queue the information rather than just using the immediate result. I think I'll write an object based system that keeps information about the callbacks. I enjoy using Unity's interface that they've come up with for the different input methods, as it makes diversity between keyboard and controller a lot easier to deal with. Thanks for the answer though.

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

141 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

Related Questions

Toggling with a key not working 2 Answers

Is there a way to detect a change in Control Scheme with the new Input System? 1 Answer

create default and customizable inputs 0 Answers

my input system dose not show up on the assets folder 0 Answers

what are the single joystick prefab's inputs for the input manager 1 Answer


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