Katagon Procedural IK Combat and Navigation System

posted in: Game Development, Miscellaneous | 0

KatagonV1Logo800

 

[kah-tuh] – noun - an exercise consisting of several of the specific movements of a martial art, especially a pattern prescribed for defending oneself against several attackers.

-gon - a combining form meaning “angled,” “angular,” used in the formation of compound words: polygon; octagon.

[kah-tuh-gon] – noun - A system for navigation and stance control based on martial arts patterns and rules for use in moving polygon based game characters around and engaging in combat and defending against attackers.

The Katagon Procedural IK Combat & Navigation System

The Katagon System was developed from research done into creating procedural martial arts based rigs using constraining splines that IK goals ride along and martial arts combat and defense theory and rules.

With a broad style of game mechanics in view a modular system was set up where keyboard or axis input determined the navigation and stance movements of the lower body and mouse left and right buttons controlled upper body movement via a procedural IK system of constraints. This allows the system to be extended to accommodate any weapon or style to be used with very few or no further animations needing to be created. By balancing of variables or adjusting spline shapes in each of the modes a wide variety of gameplay styles can be tweaked to accommodate the needs of the game mechanic attempting to be achieved.

The Katagon Procedural IK System was developed modularly and with extensibility foremost in mind without the need for creating numerous new animations to handle a new weapons or spellcasting ability for example. All parameters are exposed to allow scripting and storing series of parameters suitable to your game mechanics and character expression as presets. The first release of the Katagon System includes a sword and shield Combat Stance To Stance Mode and a FreeNav Mode the Player Avatar. The Combat Mode is based on constraining the IK Goals to a Katagon Arc Spline with controls for Radius and From and To, allowing you control of swing arc and elbow bend during Swing and Block execution. Using the constraint to spline objects system, a spectrum of weapons handling including kung fu staff, magical staff, two handed sword, shoulder or hip fired two handed rifle, spear, axe and others as well as handing complex hand gestures such as drawing runes in the air for spellcasting, martial arts strike and block bare handed techniques. Being procedural they can be adjusted, tweaked and scripted to allow variation as necessary to achieve the style you are seeking for your game character. Version V1 includes a sword and shield weapons handling system.

You can view the web player demo at Katagon V1 Demo

 

PLAYER AVATAR HIERARCHY SETUP

In the KatagonPrefabs->AddToYourCharacter folder are several prefabs that assist the procedural IK system in reacting to changes in input. You can of course replace the weapons with your own after some minimal setup for initial axis positioning and rotation and mounting offsets.

Setting Up Your Avatar Hierarchy

To set up a new Player avatar you need to drop a few game objects into the Hierarchy of the avatar. The objects are highlighted in the screen capture.

KatagonHierarchySetup

Assisting Objects

CamTarget - This is the object the Main Camera looks at. Currently it sits 0.65 units forward of the local Z axis of the avatar root at approximate eye level 1.6 units on the Y axis and is centered at 0.0 on the X axis.

LookAtObject - This is used to control the upper body LookAt and rotates the torso and head. The ‘-’ child object is a visual aid. It can be turned off or removed from the Hierarchy. It’s initial position should be 2 units forward of the avatar on the local Z axis and at approximate eye level, about 1.8 on the local Y axis and centered at 0 on the local X axis

L_ShoulderSplines – A collection of helper objects. Place at L_Shoulder position as a child of the L_Collarbone.

L_ShoulderArc - This arc is for IK Goal constraining the blocking arm IK in Stance Combat Mode.

L_HandIKGoal - The IK Goal constrained to the L_ShoulderArc

L_TargetGoalArc – This Arc is for constraining the LeftGoalTarget and is used by the L_HandIKGoal for directional targeting.

LeftGoalTarget – This transform rides the L_GoalTargetArc and the L_HandIKGoal points at it via Quaternion.LookRotation.

L_ElbowHint – The transform used by the Animator for the left arm pole vector to set the arm to more natural positions that the IK may have used.

R_ShoulderSplines – A collection of helper objects. Place at R_Shoulder position as a child of the R_Collarbone.

R_ShoulderArc - This arc is for IK Goal constraining the swinging arm IK in Stance (Combat) and FreeNav Mode. Place at R_Shoulder position as a child of the R_Collarbone.

R_HandIKGoal - The IK Goal constrained to the R_ShoulderArc.

R_TargetGoalArc – This Arc is for constraining the LeftGoalTarget and is used by the L_HandIKGoal for directional targeting.

RightGoalTarget – This transform rides the R_GoalTargetArc and the R_HandIKGoal points at it via Quaternion.LookRotation.

R_ElbowHint – The transform used by the Animator for the right arm pole vector to set the arm to more natural positions that the IK may have used

R_FootIKGoal – The RightFootIKGoal used by the Animator..

RightKneePole - The RightKneeHint used by the Animator for adjusting the leg. It is a child of the R_FootIKGoal and will properly adjust the knee position based on the foot position and rotation.

L_FootIKGoal – The LeftFootIKGoal used by the Animator..

LeftKneePole - The LeftKneeHint used by the Animator for adjusting the leg. It is a child of the L_FootIKGoal and will properly adjust the knee position based on the foot position and rotation.

RootIKGoal – This is the base root IK goal. It’s use is not implemented currently but will be used in the upcoming ObstacleNavigation Mode and Walk and Run Cycle Generator. There are child helper objects and visualizers that can also be ignored for the current V1.0.

BodyIKGoal - This is the equivalent of the PelvicRoot transform and it’s use is not implemented currently but will be used in many future additions to the Katagon System. There are child helper objects and visualizers that can also be ignored for the current V1.0.

Most objects are simply empty game objects that use the Transform to get and set input and output. The L_ShoulderArc and R_ShoulderArc are KatagonShape splines. They are used to constrain IK goal to natural limits along natural movement arcs of trajectory.

Most empty gameObject prefabs have a visual aid for use during development for tracking visually. They can be turned off or removed from the Hierarchy.

The Katagon Procedural IK Scripts

The KatagonModeController handles switching between modes by acting as a central hub. The switching is handled via keyDown input or automatically via mouseDown input. Currently StanceToStance Combat mode is toggled on using the ‘C’ key. Free Navigation mode is toggled on using the ‘F’ key.  As more modes are added to handle other combat modes such as archery or two handed sword or sword and dagger for example, these can then be added to this script and switching controlled via any input the user wishes. The ObstacleNavMode, FightMode and DamageMode are there to accommodate upcoming additions to the Katagon system currently in development.

The KatagonInputController maps the keys and mouse up, down and movement and sends the input or responds to queries for input from the various other components. The developer can remap KeyCode to whatever mapping keyboard or joystick schema they wish to use or are comfortable with or for their mechanics.

The KatagonCombatController is the brain of the combat system and controls Stance To Stance, swinging and blocking. Stance transitions are controlled via WASD keys using the following paradigm.

W = ForwardStance, A = LeftStance,  S = BackwardStance, D = RightStance, WA = ForwardLeftStance, WD = ForwardRightStance, SA = BackwardLeftStance, SD = BackwardRightStance.

Pivoting from a stance is controlled by Q = PivotLeft and E = PivotRight.

Swings with right arm are executed by LeftMouseDown first clicking on the Avatar which puts the controller in StanceMode and moving the mouse back and forth across the Avatar at various angles while the LeftMouseButton is down. At the conclusion of a swing execution the swings allowed are based on a back and forth swing progress where four moves are incremented along the arc spline and the other four decremented. Setting of the next swing angle can be controlled by keeping the LeftMouseButton down and circling around the Avatar for each side of the body. Once it crosses the center the swing executes. By holding both the RightMouseDown and LeftMouseDown the Avatar will follow thru on the swings giving a much wider sweep of the weapon he is swinging. There are currently two swords that can be turned on or off. Mount the swung weapon (can be an axe or stick or any swing weapon) in the Avatars right hand in the rig hierarchy. Letting up on the LeftMouseDown will set the controller to a Ready pose. SwingSpeed can be controlled by the SwingSpeed slider.

SwingDiagramWText

Blocks with shield are executed with the LeftMouseDown and pressing the ‘“X” key. Blocks are executed based on the mouse cursors screen position with LowLeft being the lower left of the screen and HighRight being the upper right of the screen. Letting go of the “X” key will put Avatar back to swing mode as long as the LeftMouseButton is down. BlockSpeed can be controlled from the BlockSpeed slider.

Left and Right finger poses can be set by the lFingerPose and rFingerPose float field. The lFingerPoses and rFingerPoses arrays hold the selected finger poses per block and swing.

The KatagonLookAtController controls LookAround which is executed by the RightMouseButton down. This moves the LookAtObject back and forth and up and down based on mouse coordinates with the KatagonCombatCamera moving opposite as it pivots around the CamTarget transform. At certain limits left and right the Avatar will pivot to keep the LookAtObject within extents. The horizontal and vertical extents of the LookAtObject can be controlled by the LookAtExtentHorz and LookAtExtentVert sliders respectively. LookAt Controller weights can be adjusted by the weighting and clamp sliders.

The KatagonNavigationController controls the navigation mode to use. You can use the standard WASD keys to navigate turning left, navigating forward, turning right and walking backwards respectively. If the Avatar is not moving currently the A & D keys will cause it to turn in place. If you LeftMouseClick on a collider (floors terrain, etc) tagged as “Surface” it will navigate to that point clicked on and stop. If you click on an Object tagged as “Opponent” it will navigate to the opponent and stop 3 units/metres from them. You can get the actual groundSpeed by querying the groundSpeed variable of the KatagonNavigationController. ObstacleNavigation and AutoObstacleNavigation are currently in development and will be released in a forthcoming update to the Katagon system.

The KatagonAnimatorIKController is the interface to the Animator Controller IK system. Here you can set up the weighting per IK Goal. It takes the position and rotations of the IK Goals as set per the previous scripts and sends them to the Animator Controller in the OnAnimatorIK() callback. Layer1 and Layer2 control the RightFingers and LeftFingers poses. The Animator Layers 3-6 are empty layers that control the IK passes per limb.

The KatagonEditorIK component allows full control over most parameters live in Edit Mode. It allows full control of the block and swing params and has sets of buttons to Set and Get the parameters per Swing and Block and the three ReadyLevel poses.

SwingAndBlockParamsEditing

As well you can copy and paste arrays from the Console if you wish to replace the Katagon script default arrays.

EditorIKInspectorScreenshot

The KatagonArcHandle component shows a blue pie slice arc for the R_ShoulderArc depicting it’s From and To as well as Radius parameters. The L_ShoulderArc is in red and portrays the same parameters visually as the right arc. The IK goals are shown as WireSphere gizmos and the elbow and knee hints/pole vectors as well in a slightly smaller version. Blue is for the right side and red is for the left side. This script must be open via the foldout arrow in the upper left of the component to allow the gizmos and handles to remain visible. To view the actual splines simply unfold the hierarchy and select them. You can also set To, From and Radius for each arc when selected in the KatagonArcShape component.

KatagonArcHandles

The KatagonCombatCam is added to the Main Camera. You can set the height in the Y axis and the distance in the XZ plane as well as control how fast it moves and rotates by setting the damping for each.

The Katagon Procedural IK Combat and Navigation System pdf documentation can be found at this link.

The Roadmap

Systems have already been started to be put in place as you will see if you go through the scripts. In the short term will be added an Obstacle Navigation Mode. This will include both manual, semi-automatic and automatic. A Kata Combo Sequencer for editing Kata moves and combining them into sequences to be fired off as Katagon Combos. A reactive damage and collation system will be added to react to blows and strikes from other colliders as well as report the magnitude of the blow for use in health and weapons damage systems. Also coming up will be a walk and run cycle generator to eliminate the need for walk and run animations. This will also allow the generation of any number of styles of walk and run by allowing adjustment of arm swing back to front, arm arc swing in and out, stride length and foot height during stride, hip pivot front to back and side to side, upper body sway and head counter sway. You will be able to set one style for walk and another for run and blend between the two as the navSpeed picks up. I will also be working on a one-click setup machine that will add all scripts and IK helper objects at once. Weapons handling systems on the chalkboard are two handed kung fu staff, handgun, shoulder fired rifle, numchucks would be a real challenge but I have a plan:). Bare hand combat modes will also be in development for kicks and hand strikes as well as spell casting and magical fight navigation and reaction modes. In short I want to get rid of animations altogether and via slider develop a mechanic for your avatars that are individualistic. The vision for the system when extended is contained in the infographic below.

KatagonInfoGraphic

 

This is alot of work but I have several years of research in this field and have 15 years rigging procedural and reactive IK animation setup and control. You can view clips from a showreel from 2009 of procedural animation at the following youtube links. All the animations are procedural such as the gear Rube Goldberg gadget. You set one keyframe at the start..the RPM. The same with the musical tank. All the suspension is procedurally reactive and you set one keyframe..the RPM. The Jester kicking medicine balls fired from a cannon uses the same principles as Katagon. He has no keyframes on the rig and just keyframes on sliders controlling IK goals along splines. You can help support this effort by purchasing off the Asset Store at the following link.

http://u3d.as/content/mind-release-labs/katagon-v1-procedural-ik-combat-navigation-system

Inquiries about this toolkit and other question and comments can be directed to me by sending me an email at dev@mindreleaselabs.com

 

Fight for your life!

 

 

 

 

 

Leave a Reply