Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the same action for both hands #169

Open
Rectus opened this issue Nov 16, 2020 · 8 comments
Open

Using the same action for both hands #169

Rectus opened this issue Nov 16, 2020 · 8 comments

Comments

@Rectus
Copy link

Rectus commented Nov 16, 2020

Looking at the input bindings for games like Half-Life: Alyx, and for every action that can be triggered by both hands, the same action is bound to both hands instead of having separate left/right actions.

Is it possible to set up actions the same way with the current UE4 implementation using Blueprint? Most actions would require you to know which motion controller triggered the action, but there doesn't seem to be any way of detecting it.

SteamVR Input seems to allow you to get the device ID for the action, but the MotionController component doesn't expose which device ID it uses.

@1runeberg 1runeberg self-assigned this Nov 18, 2020
@1runeberg
Copy link
Contributor

Hi @Rectus - You should be able to just map both the left and right motion controller inputs to the same action in the Key or Axis bindings and that'd produce the same "mirrored" result. Or were you thinking of a different use case?

@Rectus
Copy link
Author

Rectus commented Nov 18, 2020

The issue I have with this is how to identify which motion controller performed the action. For example if you have an action to teleport, you need to know which hand to project the teleport beam from.

@Rectus
Copy link
Author

Rectus commented Nov 19, 2020

If I understand you correctly, the inputs should be set up like this:
bild

This results in SteamVR triggering the input events, but I can't see any way of telling which controller triggered it.

My motivation with this is to present a uncluttered set of controls in the SteamVR binding interface, and to make it easy for users to rebind controls on arbitrary controllers.

@Rectus
Copy link
Author

Rectus commented Nov 22, 2020

I ended up writing a library that gets the hand for the action origin directly from the OpenVR API.

The code is here in case anyone needs it:
https://gist.github.com/Rectus/9cc3ae996df5b4549a287a37af260674

Unfortunately this has exposed another issue. It's not possible for a single action to be active for both hands simultaneously. So if you have a single grab action that's active while holding down a button, when the left hand grabs an object, the right hand can't grab objects until the left hand is has released the button.

This seems to be an issue with how the UE4 action system is designed, so I don't think there is any way around it apart from redesigning the SteamVR Input plugin to allow multiple UE4 actions to be mapped to one SteamVR action.

@Rectus
Copy link
Author

Rectus commented Mar 4, 2021

I tried making a thread on the UE4 forums about this, but not sure if anyone from Epic read it.

It would be nice to have this working in UE4 since it seems like a good fit for the level of abstraction used the XR system, especially if it can be made to support an arbitrary number of inputs instead of just the left and right hand. Considering the input system in OpenXR is so similar to SteamVR Input, it would seem like a good feature to have going forward.

@1runeberg
Copy link
Contributor

1runeberg commented Mar 5, 2021

Hi @Rectus - sorry, i lost track of this ticket. But we do already have nodes for this in the SteamVR Function Library that comes with the marketplace plugin (and with the engine from 4.24 and above). Such as:

image

You can use the node right after the action is called (event) and you should get detailed info on which controller (and part/component) triggered the action (you should of course parse first before triggering the actual action instead of the print out, but just wanted to quickly demo the output in the sample project we provided):

image

You should get a result like this:

LogBlueprintUserMessages: [VRPawnSteamVRHand] squeeze Knuckles Left

You should be able to map and respond to the same action in both hands. It's also exposed in C++ so you can build on top of this or yeah, you're free to build your own library directly from the OpenVR API, though I suggest having a look first at the SteamVR BP Function Library header as we have added quite a few convenience nodes there that you might be able to use and not need to reinvent the wheel.

@1runeberg
Copy link
Contributor

1runeberg commented Mar 5, 2021

I tried making a thread on the UE4 forums about this, but not sure if anyone from Epic read it.

It would be nice to have this working in UE4 since it seems like a good fit for the level of abstraction used the XR system, especially if it can be made to support an arbitrary number of inputs instead of just the left and right hand. Considering the input system in OpenXR is so similar to SteamVR Input, it would seem like a good feature to have going forward.

There is an OpenXR call for this xrGetInputSourceLocalizedName, the Epic plugin isn't production ready yet so there's a bunch of BP nodes that are still missing. Have passed your feedback on and it looks like this is in their radar :)

@Rectus
Copy link
Author

Rectus commented Mar 5, 2021

Thanks!

I think the ideal solution would be something that's more device agnostic though, like passing the Motion Source name or a EControllerHand Enum. Something that lets you do a select statement for devices, or on the motion controller side check if this component is the one that sent the input.

There is also still the issue of overlapping inputs being blocked. I've looked at the code for the input system, and it seems to be an intentional decision to block the inputs when an action event node is set up to listen to a pair of Pressed and Released inputs (at least in version 4.26). I'm not sure what the use of this is, but a solution might be to add a new setting to event delegate to let overlapping inputs through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants