Today's devpost is a big one and is more technical than usual. I did a great deal of work on the dynamic grabbing logic. As mentioned previously in the last devpost, custom items that the community will make will contain shapes that tell the game how to grab that object. I just finished cylinders. Let's walk through what I did before showing the final result.
The objective was to wrap around 3 finger bone sections (proximal, intermediate, distal bones) around a cylinder (the grabbable shape) regardless of the character model used (many characters have varying hand and finger sizes). At first II set out to support non perpendicular finger holds. Like this:

The fingers (blue) are not perpendicular to the cylinder (red). I just thought this would have looked cooler than the generic simple hold like this:

Straight simple hold with perpendicular fingers.
To find where to put the finger bones, the math problem was to solve where along the intersection of your finger plane it hit the cylinder and the finding the intersection of the finger circle. Because I wanted non-perpendicular finger holds, the intersected shape became an ellipse. Like so:

The orange cylinder is the item to grab and the blue blocks are the parts of a finger. The green part is the intersection of the finger plane, notice the ellipse created. The problem with doing this math-perfect approach is that this was not an easy equation to solve. Finding the intercepted ellipse in 3D and then writing napkin math to solve where it intersects a circle was just too long and probably overkill for performance. Even with some simplification tricks, it was a nightmare to write in C#. So it was back to the drawing board.

Instead, I chose to simplify the problem to perpendicular finger holds. This changed the math problem to a simple circle to circle intersection:

I wrote a new class to handle finger grab animations and I got the algorithm to work!

This works with any character hand and any cylinder radius! The next step was to smooth it out as I did not want it to pop into a grab form whenever it was near the cylinder. I threw in some linear interpolation and some smoothing:

The next problem was solving the broken fingers that occurred sometimes:

This happened when the finger tips were able to reach the cylinder but the lower bones were too far to touch it. The solution was to check if the angle created by the finger tips went backwards in a way that would break the fingers. Then, the angle was subtracted and added to the parent bone:

Looking really good so far. Remember how this approach only works when the fingers are perpendicular to the cylinder? Well fortunately I found a way to cheese support for non perpendicular holds. First, the problem visualized:

Notice how the fingers started to phase into the cylinder as I rotated it. this was because the true shape was an ellipse (which I dropped support for). The trick that I did to solve this was to just raise the fingers as the cylinder became parallel to the fingers. So if the cylinder was perpendicular to the fingers, then the fingers went up. Worked very well:

(thumb not animated yet).
And that's it! This is the new algorithm that Viva will use to animate your custom characters to grab your custom items. It is robust and will definitely look very good in VR. The next step is to wire this system up to the physics system so that you can pick up and also animate the fingers. Here is a quick test I did in Keyboard mode:

I am now gearing up for the next Beta Pre-Release that will feature the custom item system.
If you liked these technical development posts, check out the other 2 development posts I wrote a while back:
https://www.patreon.com/posts/tech-research-31048676
https://www.patreon.com/posts/tech-research-of-24229440
Stay tuned!
sgthale
2021-04-22 21:15:24 +0000 UTCrandom
2021-04-22 13:08:12 +0000 UTCsgthale
2021-04-22 06:37:12 +0000 UTCrandom
2021-04-22 03:19:18 +0000 UTCProchu
2021-04-17 15:46:12 +0000 UTC