GodotVR / godot-xr-tools

Support scenes for AR and VR in Godot
MIT License
513 stars 74 forks source link

Feature request: Hand Collision #136

Open Henodude opened 2 years ago

Henodude commented 2 years ago

I think that the player's hands should be able to collide with the environment and objects.

teddybear082 commented 2 years ago

@Malcolmnixon

Still don't have anything for the environment but for object-based interactions, I just found this addon and did a VERY quick test of adding a kinematic body with sphere collision shape to follow the index distal and seems to be a potentially promising way to potentially add at least some modular physics interactions: https://github.com/christinoleo/FollowBone3D. I was able to quickly knock around some pickable object guns and coin on a table I have in my scene and yet I was also still able to pick them up without the kinematic body interfering, which is the ideal outcome....

Malcolm's test in the XR Interactables Repo did basically the same thing to enable him to create a working button. The modular nature here though would come from the fact that the XRInteractables approach had to alter the Left Hand scene node and by extension the FPController directly, but this plugin can have the FollowBone3D node anywhere in the scene. So in theory I think we could have a parent placeholder2d node (called something like "PhysicsHands"), have FollowBone3D nodes to pertain to the left and right hand index fingers and maybe the palms or something, and a dev using XR Tools could choose to use that node or not simply by dragging and dropping the would-be "PhysicsHands.tscn" node. If I make some reliable progress and see this does not break anything I will post on this thread with a link to a repo. My guess is then too we could avoid using FollowBone3D directly (though crediting the original author) and just attach the operative script parent placeholder nodes at some point to further ease friction of the user experience....

As a real long shot perhaps if this was working there could be code to apply impulses to the player kinematic body that could simulate the effect of pressing up against environments but someone really talented would have to come up with the physics equations for that. I know in theory that's possible since sometimes I forget to use collision layers properly and wind up throwing my player character around with impacts as a result.... Now with the new improvements to the playerbody node ...who knows!

teddybear082 commented 2 years ago

Ok the FollowBone3D approach with a sphere following each index distal and a thin cube following each middle metacarpal seems really great for hitting and interacting with objects. See test videos here: https://imgur.com/a/l36CPEp

Here's a link to my github fork of the FollowBone3D plugin with instructions how to use and install a scene to create the modular "faux VR hands" in the video: https://github.com/teddybear082/FollowBone3D

psychicgoldfish commented 2 years ago

Ok the FollowBone3D approach with a sphere following each index distal and a thin cube following each middle metacarpal seems really great for hitting and interacting with objects. See test videos here: https://imgur.com/a/l36CPEp

Here's a link to my github fork of the FollowBone3D plugin with instructions how to use and install a scene to create the modular "faux VR hands" in the video: https://github.com/teddybear082/FollowBone3D

This is working well for me! How can I get hands to not go through static objects like walls?

teddybear082 commented 2 years ago

This is working well for me! How can I get hands to not go through static objects like walls?

There's no way for that yet under the current system. Right now at least it gives you haptics on things like walls and tables. I have a couple of ideas for possible approaches with the FollowBone3D system but they truly are just "ideas" - haven't tried them at all yet nor do I know at all if they would have any chance of working.

One idea could be to create new animations for the hands so then when the kinetic bodies on the FollowBone3D touches a static body it triggers a new animation would trigger to make it look like it was stopping at the surface of the static body.

Another idea could be to automatically rotate the hand mesh positions when the kinectic bodies touch a static bodies, making the hands go vertical or horizontal depending on the direction of the static body, until the kinetic body exits the surface, using the normal area-based signals for enter body and exit body.

Another idea could be to create an entirely separate set of hands attached to the same positions as the current hands but then hide the current set of hands and only use the ones attached via the follow-bone 3d and have those hands as children of the kinetic bodies so their movement could be impacted by the kinetic bodies.

I've been trying to look into whether there is any open source code to procedurally generate hand animations based on surfaces but it seems so far all I have found is paid tools for Unity that are not open source.

In the end, I really don't know. Someone was working on an entirely separate set of "physics hands" for GodotXR that would do this, but when I tried the repo, it used the SteamVR glove hands instead of the standard XR ones, the hands didn't animate and were in totally awkward positions. Here’s that repo if you want to take a look: https://github.com/jtnicholl/godot3-vr-physics-template

So it's a difficult problem to solve.

Malcolmnixon commented 2 years ago

An experimental physics hand implementation is present in https://github.com/Malcolmnixon/godot-xr-tools-interactables and allows the hands to interact with rigid bodies in the scene. At this time it doesn't prevent the hands from moving through bodies.