The FlowNode this document refers to doesn't exist since SDK release 3.5
The functionality to set IK targets to specific locations is still accessible through code by using the SetHumanLimbIK function in ISkeletonPose.
CryEngine offers direct access to the Limb IK system, which allows designers to place a limb (for example arm and hand) where they would like it - without the need for an animation. This system can be used to glue a hand to a certain object or position.
These nodes will work with any bone based character, regardless of whether it is an AnimObject, the Player or an AI. The only requirement is that the character has an IK File with any handles set up that are used in the FlowGraph nodes.
The IK Target System will bring the character's limb to the specified target, which can be provided in the form of an entity, an attachment, a bone or helper objects that were exported with a cgf from 3ds Max or other 3D packages.
All FlowGraph nodes have a couple of common parameters, regardless of the target type:
required
1. Entity - which entity/character should perform the IK.
2. Target Entity - entity to reach for (or attachments or bones or helpers on this entity.
3. IK Limb - which limb to use, for example RgtArm01 for the right arm (see section Limb IK in the IK file of the character).
optional
4. Blend Time - how fast should the IK be blended in or out.
5. Align End Effector - if checked, the end-effector(for example the hand) will be also aligned with the target's orientation.
6. Offset - position and rotation offset; for example to make the hand fit better to a markup.
This FlowGraph Node will take the entity's position and have the character's limb reach for it. This can be used for example with Tag Points. Together with the option "Align End-Effector" Tag Points can serve as IK helpers in a level or on an object.
If linked to an object, the Tag Point will move with the object, making the character's IK Limb also follow it. This creates the illusion of the character holding on to an object.
The barrel picture at the beginning of this article was created with a barrel and two linked tag points. The barrel was then moved around (using TrackView) in the level and the tagpoints and the character's hands followed. The character had LookIK activated through the Flowgraph as well.
It's generally a good idea to adjust the orientation of the Tagpoint (or other entity) that you are using as an IK target visually while the IK is active. This gives you instant feedback about the result. To do this, connect the Misc:Start Flowgraph node with the StartIK trigger of the IK node in the Flowgraph. Then hit AI/Physics in the editor.
This will trigger the IK. The next step is to select the tagpoint, and then, without deselecting it, hide all helpers. Shift+Space is the keyboard shortcut for this. It gives you a clear view of the hand. Only the transform gizmo will be still visible.
You can now use the Position and Rotation tools to adjust the TagPoints location in the level (1 for position, 2 for rotation, or use the buttons in the toolbar). The character's hand will follow as in the picture below.
This node accesses all the entity's attachments and finds one with the specified name. The attachments are regular attachments from the Attachment Manager, as they are for example created in the Character Editor. Using this, special Characters can be built with some "markup" points as helpers for the IK. This can be especially helpful when creating cut-scenes where character interact and for example to touch a specific part of a character - a point on the arm, hair, etc...
It is common practise to use special versions of characters, meaning different cdf files inside a cut-scene, so that this markup would not have an impact on gameplay or performance.
While linked tag points or attachments will follow an animated or moved object along, it could become necessary to animate the IK Target independently. To enable this, this IK Target retrieves the bone with the given name from the target object's or target character's skeleton and brings the limb to it. These can be animated which allows very dynamic targets.
It gives more freedom if a helper bone is used for this that has no mesh skinned to it. In a cut-scene it could be useful to even switch the models for this. This is useful because if used in combination with end-effector alignment it allows the hand orientation to be animated by the target object.
A very good way is to mark up IK Targets on an object when creating and exporting it in the 3D package. This way the artist can decide where the hand or limb should go.
The markers can be exported with the cgf file and this node can access them by name. As with the attachments, it makes sense to use this in combination with end-effector alignment.
To make the markers visible in Sandbox, set the console variable e_debugDraw to 15. This shows the helpers on objects and their orientation (a line points down the local y axis). Use the position and rotation offset in the FlowGraph node to adjust the hand so that it correctly grabs the object visually.
IK Target markup in Max is done by placing dummy helpers on the object, and linking it to the main object. This way they are exported along with the cgf and can be made visible through the debug draw command. Make sure to give the helpers sensible names.
The orientation of the helpers will define the orientation of the hand of the character in the engine. The axies are defined this way: The X Axis defines the direction of the fingers, the z axis is the direction that the thumb points, and the y axis points where the open palm is showing.
You can use any IK node to stop the IK on a specific limb for a character. It is not necessary that this is the same node that started the IK. IF the node is only used for stopping the IK, it is not necessary to provide a valid target entity. The value set at blend-time will be used for blending out the IK.
To stop all active IKs on a character, and not just for one limb, use the StopAllIK FlowGraph node. This node will stop the IKs immediately, without a blend-out time. Useful when entering cut-scenes or beaming the character to a different location.
With CryENGINE release 3.2.5 and up it is possible to define a spine that can be involved in the IK. This can increase a character's reach, but it also will result in a more natural look, especially with moving IK targets.
The spine must be set up inside the IK file the same way the limbs are set up. It should run from the vertebra above the one that the legs are attached to up to the vertebra that the arms are children of. For the SDK character, this will be from the Spine01 to the Neck. A spine limb is already set up in the IK file that is shipped with the SDK characters, it is called "Spine_SpineToNeck".
The same spine limb can be specified in a node for the right and the left arm. The IK Target System will try to find a spine position which will make both IK targets reachable. Since by the default setup the spine will be brought into position with a standard CCD Solver, the look can be improved by playing an underlying supporting animation on the fullbody, or implementing a new IK solver specifically for the spine.
Using the CVar ik_debug to set an debug entity. Set the CVar to 1 to debug the player character. This will display information about the current status and blendweight of the IK for each active limb of the character and render debug spheres at the start, target and intermediate positions of the end-effector.
ik_debug <entityName>
The code for the IK Target System can be found inside the CryAction dll.
The folder name is "IK System". The instance of the IK Target Manager is created, managed and destroyed by the CCryAction class itself.
The FlowGraph nodes can be found in CryAction\FlowSystem\Nodes\IK_FlowNodes.cpp
The IK target is updated in the PostProcess Callback after the evaluation of all forward kinematics for this character. Only active IKs will be updated - otherwise the callback will not be re-routed. Therefore the system doesn't create an overhead if no IK Targets are being used.
IKs can be started on any bone based character that has an entity id, a character loaded in slot 0 and a skeletonpose interface (ISkeletonPose). If an IK is already active for a limb, the active IK Target will be removed and the new IK Target will fade in from the current position (no snapping).