Setting up Ranged Weapon Hand IK - Black-Horizon-Studios/Emerald-AI GitHub Wiki
Setting up Ranged Weapon Hand IK
Emerald AI 3.0 features a built-in hand IK system that allows AI who use the Ranged Weapon Type to accurately place their hands at specified points.
Note: Emerald AI 3.0, a Humanoid Rig Animation Type, and the Emerald IK Type are required to use this feature.
Step 1
First, you will need to ensure that your AI's Ranged Weapon is attached to the AI's Right Hand transform. This allows the animation from the right hand to be applied to the weapon model and left hand. Without this, the IK process would look stiff and unrealistic. It is recommended that users position the ranged weapon as accurately as possible before continuing. This is easiest to do during runtime while the AI's Combat Idle animation is active.
You can then copy the changes during runtime:
Then paste them when not in runtime (ensure that you save the scene):
Step 2
Add the Hand IK component to your already setup AI agent. If you have not already setup your AI please see the Creating a New AI section. To add a Hand IK component, select the desired AI, press the Add Component button, and type in EmeraldAIHandIK.
You should now see the Emerald AI Hand IK component.
Step 3
Next, a Hand IK Profile needs to be created. This profile is what will store the hands' position and rotation values. To do this, press the 'Create Hand IK Profile' button. This will open up a saving panel so users can name and specify the saving location of the create file.
After you have chosen a name, saving location, and pressed the Save button, the EmeraldAIHandIK editor will be updated to look like the following.
Step 4
In order to edited the Hand IK Points, you must be in runtime as the changes need to be seen in real-time while IK is active. Starting the scene will update the EmeraldAIHandIK editor.
It is highly recommended that users do not modify the Right Hand Point as its movement and rotation will also affect the Left Hand Point. It's there in case if minor modifications need to be made.
You can be taken to the Left Hand Point by pressing the 'Select Left Hand Point' button.
This will make the Left Hand Point gameobject created by EmeraldAIHandIK the active gameobject which will allow it to be adjusted using Unity's position and rotation gizmos. If you notice, the AI's hand is not correctly placed. This is because these are the default values and will require modifications based on the AI and its weapon.
Step 5
While in runtime, you can modify the AI's Left Hand Point as needed. As you move or rotate the Left Hand Point, the AI's left hand will follow.
When you are happy with the changes (and are still in runtime) select the AI who's points were just modified and press the 'Update Hand IK Profile' button.
This will indicate that changes have been made, but will still need to be saved which is covered in the last step. You can now exit runtime.
Step 6
The AI who just had its Hand IK Points modified will now look like the EmeraldAIHandIK editor below. This means that the changes have been saved temporarily, but still need to be saved within the project. To save the changes, press the 'Save Hand IK Profile Changes' button.
This will finalize the changes made previously and you will receive confirmation that the changes are up to date.
The changes you made previously are now saved and will always be applied to the AI during runtime, unless you make further changes and save them. If you are not interested in the optional step below, the setup process is complete.
Step 7 (Optional)
Hand IK Profiles can be used across multiple AI, given that they share the same rigging/bones, so users don't have to repeat this process when it's unnecessary.
To do this, assign the desired Hand IK Profile to the Hand IK Profile slot and press the 'Import Hand IK Profile' button.
If your AI already has a Hand IK Profile, you press the Release Hand IK Profile to remove it.