Source 2 Stride Retargeting / IKChain procedural animation tutorial


Wooaaah haha stride retargeting is awesome, in this guide you’ll learn how to make that!

INTRODUCTION

NEW! Facepunch wiki page:

Ok, I could just skip making a post in the forums and make it a page on the wiki, but that way I’m not advertising this! Also, I can talk much more random shit compared to a wiki page which needs to be very formal.
Unlike with last time, where cloth physics would just benefit some models, I fully believe stride retargeting is something that will benefit most, if not all, playermodels, especially counting that this is something that was done somewhat automatically in Source 1 (if using valve biped’s m_anm animations).

WHAT YOU’LL NEED:

  • Some knowledge on Blender, or a 3d modelling program
  • Source 2 modding tools, namely ModelDoc and Animgraph Editor
  • Knowing how to make models in ModelDoc
  • Rudimentary knowledge on making Animgraphs

MODIFYING THE ARMATURE IN BLENDER

IKChains work in Source 2 very traditionally, in fact, Source 1 was the oddball when it came to lots of things (please Sam you promised you’d try to remake the Source 1 eye shader), in which you need a target bone for the IKChain that is outside of the hierarchy of the IKChain, other than that, the target bone needs to match the foot bone’s movements in the animations, hopefully, you don’t have too many to modify!

    • Having the armature selected, go into edit mode and add with ALT+A a new “root” bone
    • Add 2 (or however many needed) new bones, these will serve as the targets, so name accordingly

      shown are the root bone and the 2 target bones (selected in pose mode), the position in edit mode is arbitrary, if you want the targets to be separated from the root you can uncheck the "connected" box in bone properties > Relations.
      2
      2 distinct hierarchies are formed, with the targets being outside the one that will receive IKChains

Really only the targets are needed, but it looks better this way, next we’ll match the animations, I don’t know how you would do this in any other 3d modeling program so good luck with that lmao

    • In Pose Mode add a “copy location” bone constraint to each of the target bones
    • Making sure they work correctly (influence at 1), select all bones in Pose Mode and go to Pose > Animation > Bake Action…
    • Check Visual Keying, Clear Constraints and press Ok.
      5
    • Export animation in the preferred format
    • Repeat with all animations

CREATING FEET AND IKCHAINS IN MODELDOC

In the Animgraph, a “Solve IKChain” node only requires… an IKChain, however, what we want is the beefier version, the Stride Retargeting node (StrideR for short), which also required Feet (obviously).
In ModelDoc, with the model ready:

    • Give it a name, the “End effector bone” will be the foot bone, the last (or I guess first) bone of the IKChain, keep it with 2 bones
      7
      Note: I have not found a way to have more than 2 bones without breaking everything, even the documentation states to only have 2 bones unless we have “good reasons”
    • Press OK and then change the “Target bone” to your target bone
      8
      By default when you create an IKChain the "Target Bone" will be the foot bone, which is stupid because trying to use it like that will crash the Source 2 modding tools

9

Should look something like this, please ignore the amputated valve biped legs I used, I obviously didn’t need the rest to test IKChains, next will be adding the Feet

    • Add Foot
      10
    • Set “ankle” bone as the foot bone, then “ball” bone as the toes (what the hell kind of names are these, valve)
    • Move the “Ball Offset” to where the toe joints would touch the ground, and the “Heel Offset” to where the heel would touch the ground

      the toe bone isn't required, but the ankle definitely is, the trace has little impact so keep it more or less default

12
Should look something like this, you can go ahead, compile the model and close ModelDoc, as the rest will be done in the AnimGraph Editor.

THE STRIDER IN THE ANIMGRAPH striferd

Haha lmao get it there’s a small strider next to the title of this part, anyways, as a disclaimer, the animgraph I made is super basic, the way I get it to move towards the path is by adding a path motor that drives it towards said direction, so I don’t even need a node for it.
After having set up your usual shebang:

    • Enter your Idle / Walk state machine
    • Select the Walk to Idle transition arrow
    • Check the “Park Feet” box

      When your model stops walking, it might be caught in the middle of an awkward IKChain phase, parking the feet will make sure the feet will also reset when transitioning into this phase, in this case idle.
    • Add a “Stride Retargeting” node connected after the state machine
    • In the StrideR node, add as many feet as needed
    • Set up the feet correctly

      optional: on the bottom left of the animgraph, add a "footstep landed tag", use this in the StrideR, apparently used for footstep sounds, idk lmao can't test it without s&box (please)
    • Still in the StrideR, go to “Ground IK” > Check "Enable Ground Tracing"
      15
    • Modify any value as needed, these are all very well documented if you hover over them

In fact, all of this process is very well documented, in the “biped_standard.vanmgrph” that comes inside the default addon “Custom Character”, ever wondered what that was about huh? Well, it’s very useful to dissect, the animgraph is fully documented and commented, I could’ve saved a lot of time had I read it more closely instead of experimenting to see what works.
Oh btw you’re done


Same MP4 because I can’t be fucked, the only animation here is walking forward, but please, like the valve biped does, directional animations will be needed as you can’t completely rely only on stride retargeting, the IK Lock will immediately spring to action as soon as it gets out of hand too much, which happens frequently if you stray too far from the original animation.

AFTERWORDS

Needless to say the next guide will probably be something else on the animgraph, either a beginner guide or about however 8 way directional animations work, also it wouldn’t be one of my guide if I there wasn’t a plea for help, what the hell is this
16
Why are my pants doing the famous Michael Jackson lean, this is because of parking the feet, I tried some troubleshooting but the problem is still unknown, I hope this doesn’t happen to anyone else, my workaround was just having the StrideR BEFORE the state machine so it wouldn’t be active when it’s Idling, but I can see why having proper feet parking would be better, as every time the model slows down it completely resets the legs.
Facepunch Wiki Page later
striferd striferd striferd striferd striferd striferd striferd striferd striferd striferd
WHAT THE HELL RUN

26 Likes

grodbert back with another great tutorial!

time to make a star wars/half life rp gamemode

2 Likes

image image image
OH NO OH NO

1 Like

I did not even know animgraph uses real graphs

2 Likes

Thank you for releasing such tutorials :heart:
I never work with animation stuff, but it seems really technical :grinning_face_with_smiling_eyes:

1 Like

Damn that’s detailed, good job :smiley:

1 Like

image
I think I missed a step lmao

very good guide, wish there were more like this out there.

2 Likes

yes

2 Likes

that droid didn’t miss a step, he just drags himself

1 Like

There are multiple parameters in the StrideR node that controls the hip height, I don’t particularly know which one would be useful but there’s probably one out there.

Also there are multiple IK settings that I haven’t gone around to trying yet, one of which is the 3 jointed IKChain, called “dog bone” (because of dog’s hind legs, probably useful for furries), but every time I tried to use them it broke horribly:
image
Ouch, I should probably get around to figuring out how that works since it might be useful to you and many others.

1 Like

The guide is now proper and prim on the facepunch wiki:

maybe one day I’ll keep on trying to figure out how ikchains work better… but I can leave that to others, feel free to edit the wiki page accordingly.

I’d prefer be a jack of all trades, master of none, because when time comes I want to make something, I’ll know everything the engine offers.

2 Likes