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.
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);
}
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*.key);*
if (strokes*.state != d) { state++; if (!d) { state++; } }* if(d||state>0){strokes_.DoIt(strokes*.Number, state); }_ _strokes.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”); }