Skip to content

Use VR controllers as trackers while preserving accurate hand tracking #2794

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yurec0977
Copy link

We have a VR project — a machine gun simulator — where we use a real physical model of a machine gun. Our goal is to track where the user is aiming with the real machine gun and transfer that data into the virtual world. At the same time, we also need to track the user’s hands so that the player can see their virtual hands and accurately grab the machine gun handles.

To achieve this in Unity3D, we had to treat the VR controllers as trackers, and then extract tracking data from them in Unity accordingly.

Yurii Seredovych added 2 commits April 14, 2025 11:00
This gives possibility to track real world object and hands in the same time. As example to track aiming of stationary placed real world gun by attached controller to it. And in the same time still have hands skeletones in game.
Comment on lines 59 to +62
(DETACHED_CONTROLLER_LEFT, "/user/detached_controller_meta/left"),
(DETACHED_CONTROLLER_RIGHT, "/user/detached_controller_meta/right"),
(FAKE_TRACKER_LEFT, "/user/fake_tracker/left"),
(FAKE_TRACKER_RIGHT, "/user/fake_tracker/right"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the DETACHED_CONTROLLER_* devices?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sending motion data from the controller while treating it as a tracker — both when it's detached and when it's held in hand. That's why I decided to separate out dedicated devices for this purpose.

I also assumed that you might have plans for handling detached devices in your own way, and I didn’t want my specific implementation to conflict with your future design.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for example when the left controller held, the hand position is duplicated between HAND_LEFT AND FAKE_TRACKER_LEFT?

Copy link
Author

@yurec0977 yurec0977 Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using controller as fake tracker mode is on i don't send HAND_LEFT motion data, Just FAKE_TRACKER motion data is sending and skeleton data for hands

Copy link
Member

@zmerp zmerp Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll propose a different solution. Let's have the client send either held controllers or detached controllers (depending in the controllers proximity to the hands), and on the server side decide if to recombine the controller positions into a single device position. Detached or held controller motions would be mutually exclusive anyways.

If i was to redesign the Tracking structure, i would add a is_left/right_detached booleans, so HAND_LEFT/RIGHT would suffice for your usecase. The problem is we can't make breaking changes yet (but we are planning to)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I actually did just that — I was sending motion data from detached controllers into HAND_LEFT / HAND_RIGHT when the controller wasn’t held.
However, I was concerned this might interfere with your future plans for detached controllers, so I decided to isolate my functionality by wrapping this data into separate virtual devices instead.

If you're okay with the client writing detached controller data into HAND_LEFT / HAND_RIGHT when the controller is not held, I’m happy to switch back to that approach. I’ll then handle the interpretation on the server side in a way that fits my use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, use the first solution I mentioned, which is to properly implement detached controllers on the client side. On the server side you would read from both detached and held controllers, whichever is active

Comment on lines +51 to +52
FAKE_LEFT_TRACKER_ID = PathStringToHash("/user/body/left_elbow");
FAKE_RIGHT_TRACKER_ID = PathStringToHash("/user/body/right_elbow");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I waited to implement support for detached controllers is because we don't have a way of redefining which tracker should be used for them. Hardcoding some specific tracker might be annoying and even surprising for the end user. I would suggest to make it configurable on the settings side.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. I'll do it asap.

@zmerp
Copy link
Member

zmerp commented Apr 14, 2025

The check fails seem to be unrelated to this PR, we will fix them ASAP

@zmerp
Copy link
Member

zmerp commented Apr 14, 2025

Whenever you can, rebase your changes on top of the latest master to remove the lint errors. Please rebase and don't use merge commits

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

Successfully merging this pull request may close these issues.

2 participants