mordentral / VRExpansionPlugin

A UE4-5 VR framework
https://www.vreue4.com
MIT License
543 stars 113 forks source link

Welded body driver for finger collision not working #39

Closed loicmacken closed 1 year ago

loicmacken commented 1 year ago

I am running the latest version of the plugin example and am trying to get the finger collision to work. I am especially interested in the Welded Body Driver shown on the website, since it shows off some really nice finger physics. I don't have an Index, however, so I can't use the openXR gestures directly. I am running a Quest 2 and I managed to add some manual overrides to the finger curls based on touching and pressing buttons, which work well.

However, the collision shape of the hand doesn't change at all, so the welded body driver does not appear to work. It remains the same as the physics asset no matter what I do. I actually tried it on an Index as well and it also didn't change.

Headset: Meta Quest 2 (airlink / cable) Unreal version: 5.2 Plugin version: Latest example (VRExpPluginExample-master)

mordentral commented 1 year ago

The welded body driver only functions in the example when the physical hand is being used. It doesn't get initiated otherwise (as there isn't as much of a point otherwise). It could be set to initiate with standard hands though if you wanted to for some reason.

It works fine in the example with physical hands when not holding anything, you can't use the collision visualization to see the changes because the engine draws that off of the body structure and doesn't actually poll each shapes transform (for some reason). You can verify though by forcing the AnimBP to use one of the closed hand or pointed finger poses and ram it into a wall. The curled in fingers will not collide until they contact, matching the animation.

Also the engine has several core level welding issues with skeletal meshes that are in the way of it functioning when holding something currently. Skeletal meshes welded or constrained to other meshes have massive issues where the collision gets entirely screwed up, I cannot fix that part of them in UE5 until the engine gets fixes. You could test in 4.27 to see them with full functionality though.

loicmacken commented 1 year ago

Hmm it still doesn't seem to work, the collisions don't change at all compared to the physics asset.

I am using the physical hand, it is set in the character and I verified that the grasping hands have IsPhysicalHand set to true.

I edited the animBP and am using different animations, but they don't change the collision. Specifically, I changed the grasping blend to go from a new "stretched" animation to the grip and I manually call "SetDynamicFingerCurls" on the grasping hand to change the finger curls, which works well visually but not with collision. I also changed some things to make it use the dynamic pose instead of the animated pose.

Even when not holding something, it doesn't appear to work...

In the grasping hand, in the function "Setup Physics if Needed" it calls "Setup Welded Bone Driver" with as bone inputs only "hand_r" in an array. However, it also has a disconnected pin with an array of each finger, not sure if I have to do something with that? I tried connecting it but it didn't change anything.

I don't see any errors or warnings in the log, so any idea what could be going wrong?

Thanks for the help btw and for the plugin itself of course! You're doing the community a great favor :)

mordentral commented 1 year ago

You know? It works but chaos has an extra shape change that was throwing it off. It can be fixed by refreshing the welded driver later on, but now that we are on Chaos anyway I have access to the special shape data.

So instead of just re-wrote part of the welded driver to work off of the special data instead, should be a lot easier to work with in general. If you update to the latest of 5.2.1 (either repo) it should work for you now without refreshing the driver, and be more consistent in general.

You still need to refresh the driver on detachment / attachment as it also can disable the sleep state of the hand, which is important to keep it from clipping into things from the animation change if the hand is at rest.

loicmacken commented 1 year ago

I updated the plugin and it works now!! Great work and thanks a lot! 💯