Setting Up Ground Conforming
Section 1: Control Rig
We will be using the Titanosaur as an example creature.
Create a “Rig” folder under Titanosaur. Locate Game/PrimalEarth/Dinos/Trike/Rig/Trike_GroundConform_CtrlRig and copy it into the Rig folder of the Titanosaur. Rename it to Titanosaur_GroundConform_CtrlRig
Open the Control Rig and in the Rig Hierarchy, select all bones and delete them.
3. Import the Titanosaur hierarchy.
4. Open the Preview Scene Settings tab and select Titanosaur as preview mesh.
5. Unplug the Forward Solve node so that you can see the skeleton in reference pose.
Select all the bones that you want to be simulated. This is the equivalent of adding physics bodies to a selection of bones.
Now drag the selection into the graph and choose Create Item Array.
6. Duplicate the array and replace the old arrays that are commented as “Effector Bones” and “Parent Bones”.
For each effector, define its parent in the parent bones array. The parent bone needs to be one of the effector bones, with the exception of the root bone.
7. Make sure that all “Settings_*” variables have a length equal or greater than the effector bones array.
8. Connect the effector and parent bonres array to the function GroundConform_Constructor. If you get warnings about node run limit, increase it in the Class Settings:
9. Connect the Forwards Solve again.
10. Adjust Settings_TraceRadii until you can see the red collision spheres. Always compile to see the changes to default values. This can be fine tuned later in the map.
11. Go to the Full Body IK node and set “Root” to the hip bone, or the first bone that comes after the root bone. Remove all array elements of the Bone Settings.
Section 2: Hooking up the Control Rig in the Character Blueprints
Creating the AnimBP Linked Graph
Right-click the Skeletal Mesh and create a new AnimBP. Name it Titanosaur_GroundConform_AnimBP. Move it to the Rig\ folder.
2. You can copy-paste the nodes from Sauropod_GroundConform_AnimBP into the new AnimBP.
3. In the class defaults of the new animBP, make sure "Use Main Instance Montage Evaluation Data" is checked. This links montages from parent to the newly created animBP.
4. Select the Control Rig node and set the class to the Titanosaur_GroundConform_CtrlRig.
4. Right-click the Anim Instance node and choose “Create variable”. Click the Eye icon to make the variable “Instance Editable”. Compile and save.
This variable must be named AnimInstance so that the linked anim graph works. It must also be marked as editable or the editor will crash.
5. Copy-paste the event graph of the Dodo_GroundConform_AnimBP into Titanosaur_GroundConform_AnimBP. Then right-click the “Set Variable” nodes and choose “create variable”.
Note: Some dino animBPs may have extra vars in their update function, but the ones listed above are mandatory to get basic functionality working.
6. In the Anim Graph, to connect the new variables “isBeingDragged” and “bSwimmingMovement”, etc. to the Control Rig. You will first have to select the Control Rig node and choose “Use Pin” for the inputs to be exposed. Also make sure these variables are set to 'instance editable' in the control rig itself, else the "Use Pin" option will not be available.
Dino Dragging Setup
We are also able to drag dead dinos using GroundConform so that their tails/limbs all use proper IK. The setup is very simple
To set up the dragging logic for dinos, add a Transform (Modify) Bone node with the “Bone to Modify” set to the hip bone. Make sure the translation mode is set to “replace existing”, and “interp result” is checked in the Alpha tab. This logic ensures that when dragging the dino, their hip will be more or less attached to the player’s hand. If it’s still not centered, you can add values to the translation vector to offset its position. Furthermore, you can try altering the translation space for better results.
Make sure the variable “IsBeingDragged” is plugged into the dino’s control rig properly. Else the above logic won’t matter.
Torpid Conforming Setup
Because we're using the same GroundConform logic with a dino's torpid state, we need to make a few changes to the graph and animation assets.
Replicate the setup below after the control rig node. Replace “Dodo-Torpid-Idle” with the dino’s equivalent. Make sure the “Apply Additive” node has an FInterp alpha of 5, or else the pose will snap when it comes out of sleep.
Add an EnableGroundConforming metadata curve to the dino’s torpid idle animation asset. This ensures the animation won’t deviate from its conformed state.
In the Torpid-Eat animation, set the additive settings to “Local Space” using the dino’s Torpid Idle for the base pose. Also add the EnableGroundConforming metadata curve.
In the Torpid-Eat-Montage, set the slot to TorpidEatGroup.TorpidEatSlot. If this option isn’t listed, go to Window > Anim Slot Manager, and make a group/slot using that naming convention. This will require you to save the skeleton!
For torpid eating, in the GroundConform_AnimBP, add a montage node using the aforementioned TorpidEatGroup.TorpidEatSlot. Hook this up to a layered blend per bone node with the dino’s head/neck literal bone name. Blend Depth is optional.
Because we’re using GroundConform on the torpid states, we need to alter its Torpid-In and Torpid-Out animations and montages as well.
Add an EnableGroundConforming curve to the torpid in and out animation assets. The look of the curve depends on the animation, but the curve will be 1.0 when it is torpid, and 0 when you no longer want GroundConform to affect the dino.
In the corresponding montages, set the Blend In time to 0. The Blend Out time varies and relies on testing -- an off blend out will result in hitches when transitioning from torpid to waking.
Here is a general overview of what your AnimGraph should look like with everything implemented. The torpid logic is most variable to change -- For example, in the photo above, the Allosaurus has its own TorpidArmPose, which only affects the left arm. Very case-by-case.
Setting up the Character_BP
Open Titanosaur_Character_BP. In the Class Defaults, search for "death" and make sure the "DeathAnim" montage slot is set to None.
Search for "Ground Conform" and check that "Enable Animation Ground Conforming" is set to true.
Disable “Death Use Ragdoll”
Add your directional death blendspaces to the Death Animations map, using this exact naming convention. Each string corresponds to a different type of death. NOTE: While blendspaces are most commonly used, individual animation assets or montages can be used as well.
Compile and save.
Link the Anim Graph
Open the Anim Blueprint. To find the correct AnimBP, select the Mesh inside of the Character Blueprint “Components” list. In the details panel, check what Anim Class is selected.
Then hover the mouse over the AnimBP to find the Parent Class.
Another way to find the parent class is to open the Titanosaur_AnimBP and click at the edit button in the upper right corner.
2. Check if this parent AnimBP has a GroundConform Linked Anim Graph before the Output Pose. If it doesn’t, you will need to create a GroundConform_AnimBP for the dino of this AnimBP.
Right-click an empty space and type “Linked Anim Graph”
After creating a Linked Anim Graph, fill in the Instance Class with the *_GroundConform_AnimBP and the Tag field with “GroundConform”
Drag out from the Anim Instance on the newly created Linked Anim Graph and create a “Get a reference to self”
You can now connect everything up to look like this:
For example, let’s say we are working on the Basilosaurus and the parent class DinoBlueprintBase_RootTransform does not have the linked graph added yet. It uses the Ptero mesh so now we have to create an AnimBP called Ptero_GroundConform_AnimBP and put it into Ptero/Rig/. To use this as a placeholder, add the AnimInstance variable and make it editable. Add an Input Pose node and connect it to the Output Pose. Now you can place this Ptero Linked Anim Graph in the DinoBlueprintBase_RootTransform AnimBP and set the Tag to GroundConform. Now that we have the linked graph in the parent class, we can continue.
Wrapping Up
Let's do a quick checklist on the parent class, to make sure it's ready for directional deaths and death conforming.
Make sure there is a montage slot named 'DeathSlot' in the parent AnimBP as well, or else none of the deaths will play! Your anim graph should look something like this once everything is connected.
2. In the Event Graph, make sure you have this code before everything in the Animation Update function, as well as Event Blueprint Initialize function. We use this to link and unlink our Groundconform_AnimBP from the parent graph when needed.
Lastly, we just need to make sure the dino's original animBP is adjusted. In the class defaults, set the "Ground Conform Instance" to the new Dino_GroundConform_AnimBP.
6. Test if everything is hooked up correctly. Play in editor, spawn a dino and kill it to see the ground conform system activate. Also test if groundconform works with torpid states:
cheat spawnactortamed /Script/Engine.Blueprint'/Game/PrimalEarth/Dinos/Titanosaur/Titanosaur_Character_BP.Titanosaur_Character_BP'
cheat killaoe tamed 10000
To test torpid states:
cheat setmytargetsleeping 1
cheat setmytargetsleeping 0
cheat gfi berry_a 100 0 0 (to test eating anim)
To view the debug draws of the control rig, use the command:
a.AnimNode.ControlRig.Debug 1