How do I make a hand's fingers bend based on the position of the grip on a VR controller?

I want to be able to make the fingers bend based on how much the VR controller grip is pressed down.

For example:

I believe VR controllers are treated like any other controller, so you should be able to detect how far down your grip is pressed like how you would on a controller.
Here’s a drawing showing what’s mapped to what for a vive controller.
Here’s a thread discussing how to get the “depth” a trigger was pressed down with.

1 Like

I am able to detect how far down the grip is, but how would I go about bending the fingers based on the value I get? Would I need to make an animation?

I imagine it’d be a fully rigged hand and the grip amount would represent a frame in the animation. So you could use the grip strength to get a particular frame in the animation if that makes sense?

So what you could do is, if you know the animation length ahead of time, you could use math.clamp(gripStrength, startFrameValue, endFrameValue) to get a relative keyframe timestamp to set the hand to?.

Hope that makes sense. :smile:

1 Like

Okay, let me test it out. Thank you.

1 Like

You could also use animation weights with static looping poses to achieve a similar effect I imagine. Just keep in mind if you set the weight of an animation to 0 it breaks it, you wanna set it to like 0.001 instead

1 Like

So how do I set the animation to a specific time then? I’ve searched around, but I’m not sure how to.

I believe animations can have keyframes, but you need to define them. A better way I think is to set the TimePosition of the AnimationTrack if you can, based on that grip strength value. It’d be the same way with math.clamp, you’d clamp that grip strength value based on the animation track’s length, like so:

local animationTrack = <animation track here, however you retrieve it>
local timePositionToSetAnimationTrackTo = math.clamp(<grip strength value here>, 0, animationTrack.Length)
animationTrack.TimePosition = timePositionToSetAnimationTrackTo

Something along those lines. You’d have to make it so the animation doesn’t have an animation speed at all, otherwise it would play the animation past that point.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.