So my project for today is to finish my grab function for my player character. The issue I am looking to tackle is the variable lengths an item can be to still be within the grab range.
In all three instances, the red ball/apple is within grabbing range of the character, but all three would be different animations considering the different extension/bending needed in the arm.
To handle this, I am thinking about trying to extract the world position of the generic target object and then passing that information to the hand of my character and making a location keyframe. Then just animate the fingers and such to wrap around the object sufficiently. Hopefully, if it goes as expected it will make it so one animation can serve as many.
What do you guys think of this approach, think it will work? Think of a better one I should try instead?
I say, if your arm is rigged correctly, just use a Track To + Motion actuator setup to move your hand towards the object until it touches, then play the grab animation. Just have it stop if the hand is at a certain distance away from the player.
A) The simplest method is when there is just one possible option. The character stays at a defined place with a defined orientation. The object to be grabbed us at a defined position and orientation ( which matters if it is not symetrical ). Then you can simply play the grabbing animation.
B) The next one is a bit more complex but basically the same. You can have several animations for different distances. Obviously it is a repirition of option A) not much more flexible, mainly just more work.
C) you mix two or more animations that way that the resulting animation can end in any distance e.g a short grab and a long grab. This is a very dynamic method, but you need to be careful with the combination. There are some natural limits when the resulting animation does nor look normal anymore. You can compensate by mixing two other animations short grab … long grab … far grab.
You can use option C) to control the side grab too. Be aware the natural range is not a rectangle. It is more a bow or bean shape.
have your IK handle for animating the hand be a empty, parent it to the physical mesh, this will allow you to animate it normally, also if not playing a animation, you can use
p1 =Hand empty
P2 =Target
D = p1.getVectTo(P2)
own[‘Timer’]=200
own[‘Dist’]=D[0]/200
own[‘Vect’]=D