Hi All,
Is there a way to create key combinations, such as "shift-A" or "ctrl-A" instead of just "A" in the "Actions & Inputs" interface or programatically?
Thanks
Hi All,
Is there a way to create key combinations, such as "shift-A" or "ctrl-A" instead of just "A" in the "Actions & Inputs" interface or programatically?
Thanks
Only with the power of JavaScript's boolean operators XD The Actions & Inputs system is device-agnostic and doesn't include additional logic for keyboard modifiers.
I would create a new action called CtrlModifier
. Then, in the code, I would detect key combinations like this:
if (ct.actions.CtrlModifier.down && ct.actions.Select.pressed) {
selectAll();
}
The trick is looking for down
state for the modifier but looking only for pressed
state for the main key. This assumes that you don't need to listen for cases when someone holds A firstly and then presses Ctrl. But if you do, you would add an additional clause like the following:
if ((ct.actions.CtrlModifier.down && ct.actions.Select.pressed) ||
(ct.actions.CtrlModifier.pressed && ct.actions.Select.down)
) {
selectAll();
}
Actually, it's a bit easier for the first case:
if (ct.keyboard.ctrl && ct.actions.Select.pressed) {
selectAll();
}
Thanks @CoMiGo. I considered that approach, but it seemed contrary to the idea that Actions should be device agnostic: an action might be a button on one device and a key combo on another.
But this is what I’ll go with for now. My game has enough reliance on the keyboard that it likely wouldn’t translate well to another device anyway.
lazza What are your other devices and overall input requirements? I think that any keyboard scheme nicely fits into gamepads... until you need to use all the 104 keys. Shoulders/triggers can act as modifiers for gamepad keys, and touch devices can benefit from movement speed and other gestures, though it ofc requires additional coding.
Here goes…
The game has 3 "characters" controlled by a single player, but only one is active at a time.
So all in all, even though there seems to be a lot of complexity, I've boiled it down to 6 keys: up, down, left, right, shift and x.
I would do it this way:
Wow. This is fantastic input (pun intended!)
The clickable avatars idea fits perfectly. (I’m already using that as a heads up display that animates when you switch characters) but I hadn’t even thought of what the experience would be on a touch device.