Hello, everyone! I started using input prototype yesterday after hearing about it on the Debug.Log() podcast. I’m really liking the system so far, especially the blocking queue (I was actually just in the middle of implementing my own system on top of the standard Unity input for this using something akin to the way layer masks work and some RAII stuff, so this saves me some time ). I had a comment about the documentation though. It is written very clearly for games in which the player is represented by some type of avatar. I get that this is probably the most common scenario, but for strategy games this is not necessarily the case. I eventually decided upon just sticking the PlayerInput component onto an empty object that represents a player being in the game. It may seem insignificant, but more clearly spelling out something like this for a strategy game scenario may be beneficial to people trying to figure out how this works.
My question is with detecting which devices are present in the active control scheme. I have some scripts that should work differently if the input device is a mouse or an analog stick (a targeting cone that should size and point itself instantly to the mouse cursor or simply rotate and expand based on analog stick input). Right now I have hardcoded to check the control scheme name. If the active control scheme’s name is “KeyboardMouse” then it does the mouse code, and if it’s “Controller” then it does the gamepad stuff. It works, but I don’t like hard-coding things like strings or literals. I dug through your source code and found some functions that check for an input device or returns a list of input devices, but what if I just want to say “Hey, ActionMap, if the current control scheme has a mouse in it do this thing”? This will prevent typos in the future and doesn’t force me to remember in my action maps whether I call my Keyboard + Mouse setup “KeyboardMouse” or “MouseKeyboard”.
Another question is modifiers. I would like to add in “Shift+W” as an action input, but I only see options for single keys. Do I have to add a “Modifier” action assigned to the keycode of the left shift button (shift doesn’t seem to be labeled yet) and then check both actions in order to gain this behavior?
Moving on to the possible bug I found: the ActionMap inspector. I made a couple action maps. One is for camera controls and the other is for my targeting cone interface. As the attached screen grab shows, my TargetingAM action map has several sub-assets which are also called “TargetingAM” and only one of the sub-assets are named after the actual action it represents. My camera action map seems to be working just fine though. The inspector seems to think the the main action map asset is one of the sub-assets as well. When I click on what appears to be the main asset it tells me to select the main action map, which happens to be the last sub-asset called TargetingAM for whatever reason.
The control scheme has a property for getting its associated device types, so you can do something like this:
myActions.controlScheme.deviceTypes.Contains(typeof(Mouse));
We could also expose a method for getting the devices that the ActionMapInput is currently using.
We don’t have support for modifier keys yet, but it’s on our todo-list! Currently there is no good way. What you suggested could work but of course is not a nice design.
Right. There are some bugs in 5.3 and earlier related to sub-assets in ScriptableObjects. I’m currently trying to find out if they are still present in 5.4 or have been fixed.