Way to tell if PlayerActions key is held down

User Story:

As a developer, it is currently not possible to seamlessly transition between multiple CAS hooks for PlayerActions inputs. If the bound key is held while another CAS action is active, and then that action is unbound, I would like for the now-active second action to continue off, knowing that the key is held.

Use Case:

Let’s imagine I have a jetpack bound to PlayerActions.CharacterJump. The player holds jump to boost upwards, and when they run out of fuel they fall to the ground and revert to the default jumping behavior. Since the player held jump when the jetpack action was bound though, when the jumping action takes over it doesn’t know jump is held. Normally when jump is held, the character will repeatedly jump, but since the new action doesn’t know jump is held, nothing happens. I have to release the jump key and hold it again to continue jumping.

UIS::IsKeyDown() only works with KeyCodes, so I can’t use it to check PlayerActions keys. I could use UIS::IsKeyDown(KeyCode.Space), but I would have to check all keys for every platform which is a little ugly. It also wouldn’t be forward-compatible in the event we allow users to rebind their keys and they change Jump from Space to something else. CAS does not have an equivalent method.

1 Like

Unfortunately this probably wouldn’t give you what you really want, since PlayerActions only maps to WASD and Space right now. I had some different ideas regarding rebindable controls though.

My grand vision is something like having Studio UI to create some “BoundAction” type of object that can be passed with the input types to BindAction, and then you’d be able to specify whether or not users can rebind it and provide a default binding. We would probably then create some default ones in new places that cover the character controls.

Bear in mind that this is just my eventual idea for it, it’ll probably go through a few revisions and I’m open to input on it.

Yeah, for user-customizable controls PlayerActions aren’t a great fit since there’s not many of them, but for this specific use-case they’re fine. The goal is to bind to jump regardless of platform, so PlayerActions work. The alternative would be to either:

  • Have players suck it up and re-press space when they land until BoundActions are implemented
  • Individually check each platform’s jump keycode (which isn’t possible for mobile) with UIS::IsKeyDown

Neither are particularly ideal.

If PlayerActions are on the road to deprecation though, it wouldn’t really make sense to implement a feature like this. I’ll see if I can find some sort of workaround in the meanwhile.

I agree with your general sentiment, it’s just that I don’t think it’d be consistent with current behavior if we made IsKeyDown(Enum.PlayerActions.Jump) return true while the touch button is pressed or the A gamepad button is pressed.

It’s probably about time to deprecate PlayerActions in favor of something more forward-thinking, or just implement this functionality across the board and revitalize PlayerActions. I’ll discuss it with darthskrill tomorrow.

1 Like