- Изменено
IK to touch a world prop
My character reaches out to touch various props in the world and I'd like to use IK so the spot on the prop can variable by a few pixels and they always touch the correct spot. Is that possible? I've seen demos where some point a gun at a spot and haven't had any luck tracking down the code.
You can position a bone (the IK target) where you want them to touch. What runtime are you using?
I'm using the c++ runtime. Position the bone at a world coord?
You can use Bone::worldToLocal to set the local Bone x
and Bone y
. Remember in world coordinates 0,0 is the position of the skeleton (Skeleton x
and Skeleton y
). You'll need to Skeleton updateWorldTransform
after changing the bone's local transform. Also note applying an animation may change your bone position, if it is keyed. In that case you can modify the bone's local position every frame, after applying animations.