Creating Dynamic Character Movements with Foot Inverse Kinematics and Open-Source Code

  Переглядів 25,991

Nick Maltbie

Nick Maltbie

День тому

In this video, you will learn how to use inverse kinematics (IK) to make your characters walk like a pro on any terrain. You will see how IK can improve your animations by keeping the feet on the ground, adjusting the foot rotation and angle, and moving the hips and knees accordingly. You will also learn how to implement IK in your own project using an open-source example and some simple code. By the end of this video, you will be able to create realistic and dynamic character movements with IK.
Reference documentation - nickmaltbie.com/OpenKCC/docs/...
open-source project - github.com/nicholas-maltbie/O...
Chapters:
00:00 Keeping Feet on The Ground
04:27 What is Inverse Kinematics (IK)
12:01 Foot Placement Algorithm
20:16 Mixing Animations and IK Constraints
23:50 Edge Cases
29:15 Future Improvements
#gamedev #unity3d #inversekinematics

КОМЕНТАРІ: 47
@MatthewTrecozzi
@MatthewTrecozzi 10 місяців тому
I'm looking forward to the premiere!
@jmifyourelazy8312
@jmifyourelazy8312 10 місяців тому
These videos are always so interesting, love the depth you explore on each topic.
@NickMaltbie
@NickMaltbie 10 місяців тому
Thanks, glad you like them!
@Maite-AileenBrandt
@Maite-AileenBrandt 8 місяців тому
Damn, thank you very much for sharing and even explaining in detail your experiences and theoretical background on the IK topic! Since I didn't want to create animation for a past project I dived into that topic a liiittle bit as well ... and got pretty much overwhelmed by the complexity of creating IK movement for a character's feet (so I ended up skipping the lower body for that project and using IK 'just' for movement of arms and hands, lol). Also, you are a hero for sharing your work as Open Source on GitHub as well. \ :> /
@user-yn1oi6iv1f
@user-yn1oi6iv1f 10 місяців тому
I literally just recently subscribed and started watching a playlist about this character, and here is a new video :D
@NickMaltbie
@NickMaltbie 10 місяців тому
I'm happy you like the videos! Let me know what you think of this one when it goes live.
@user-yn1oi6iv1f
@user-yn1oi6iv1f 10 місяців тому
​@@NickMaltbieI'm kinda new at unity, and I've only done 2D minigames before. I want to make a 3D game, so I'm looking at how to make a character controller. This will definitely be useful for me.
@NickMaltbie
@NickMaltbie 10 місяців тому
@@user-yn1oi6iv1f I’m happy you find the series useful! All the code for the project is open source so feel free to reference it however you like for your projects.
@SillyOrb
@SillyOrb 10 місяців тому
Another good video that first covers the basic concepts required to then explain the core topic, all in one convenient, informative and entertaining package. Also in the video: Big bunny bonus, so keep watching. :D
@NickMaltbie
@NickMaltbie 10 місяців тому
Thanks! All the feedback on these videos has helped me improve my style a lot. 🐰🐰 bunny content is fun reward for end of long video.
@jdhgeui2838
@jdhgeui2838 10 місяців тому
NICK IS BACK HELL YEAH
@NickMaltbie
@NickMaltbie 10 місяців тому
Making and editing this video took two months, hopefully next one will be smaller in scope :)
@tianqigao869
@tianqigao869 10 місяців тому
awesome tutorial!
@NickMaltbie
@NickMaltbie 10 місяців тому
Thanks! I couldn't find any other good tutorials on the topic so I thought I'd make my own.
@hogoromootsutsuki4079
@hogoromootsutsuki4079 8 місяців тому
I hear you say several times in here that you are not an animator, however animation is relatively easy. if you have access to blender and know how to use it, all you need is the mixamo addon which has a tool that configures a rig controller, its an ik rig thats fully configured, I have created a few animations already, including weapon animations such as sword swings, just beginning to learn how to manage animation clip lengths based on degree of motion within a clip, longer clips for bigger motions, trying to create a fighting game with nice smooth animations. came here to figure out an ik solution to sort out an animation error. in my setup I use a child of modifer on the characters hands and linked them to a bone representing a sword. got it working on the import rig, and even on the same character model but without the sword bone, but retargeting had the bone position be off your ik solution saved my project.
@JustDezz
@JustDezz 8 місяців тому
Cool video, thanks! Could you also explain, how did you create animator controller for this character without using transitions? I know about Animator.CrossFade, but using fixed blend time for each transition doesn't work very well for me. Do you just store all transitions in some custom script/SO or don't bother and use some fixed time?
@cool123xl6
@cool123xl6 3 місяці тому
It looks very natural! Only thing that stood out to me as a little unnatural was the jumping where she leaps off like a frog with her legs fully outstretched. I think applying a slight downward force first so that the character springs up out of a crouch instead would look a bit more realistic.
@THE_ONLY_REAL_WAFFLE
@THE_ONLY_REAL_WAFFLE 10 місяців тому
Nice 👍
@NickMaltbie
@NickMaltbie 10 місяців тому
Thanks!
@jakobanzengruber8688
@jakobanzengruber8688 3 місяці тому
Great video! Can you share how you created that Editorscript for automating the process of creating the curves for the animation. It would help me a lot😃 Edit: Nvm. I found it in your NPM Package thank you and keep up the great work!
@animaterob
@animaterob Місяць тому
Thanks for the video. Is this only for humanoid? What about creatures who use generic avatars?
@NickMaltbie
@NickMaltbie 4 дні тому
The same principles would apply. Instead of setting humanoid foot IK targets you would need to setup custom ik targets and configure them in the unity animator rig. I haven’t done it before but I want to setup a bunny character controller in the future that would need IK targets for ears as well.
@Need2pee
@Need2pee 7 місяців тому
Could you add events to your animation at places where it steps on the ground during a walk and then do/call the ik raycasts only on those events that would make it work!?
@NickMaltbie
@NickMaltbie 7 місяців тому
It could work but would have a few edge cases that wouldn’t work like moving ground or if the player’s foot clips into the ground. But if you are looking for optimization for objects far away from the camera and there are lots of them this could be a worthwhile trade off.
@watercat1248
@watercat1248 15 днів тому
I don't use ik for my game but I don't have the weapon hold animation isuouse that you mentioned 😅 Because in my character that hand animation and the leg animation it's different object taknly. My character it's robot so it makes sense that the hands it's indepeding and have 0 effect for the leges technically my player have wheel not leg's but important part that the hands are different entaty and have 0 effect for the walking animation. That is perfect for my fps game.
@NickMaltbie
@NickMaltbie 5 днів тому
This is a common solution to split objects up into different components to be animated independently instead of using procedural animation and IK. This is also done for things like hair, capes, eyes, mouths, etc… good video for a future topic. Specifically the legs and feet often need manual adjustment to keep the player’s feet from clipping into the ground or walls.
@Omnivoid22
@Omnivoid22 9 годин тому
I wish you showed how to do all of this.
@ficolas2
@ficolas2 10 місяців тому
Hello, I am using your controller library, and I wanted to ask something, and point something out. This is a bit unrelated to the lib, but if I want to modify the animations packed with it, that are contained in an fbx, with no model, just the animation, how can I do it? I tried importing into blender, but then I couldn't export them again Also, the IK controller, doesn't account for the hip rotation when the controller starts, so if the character is rotated, because of a coordinate system change (like blender unity) or for some other reason, the feet point to the side. I fixed this, but it's a bit botchy, I may make a merge request if I manage to find a non botchy way to fix it. Another thing I want to point out is, the jump animation looks weird on landing, because the capsule collider hits the ground before the animation bones do. To correct this, either the collider size needs to change to be animated, or the animation needs to be modified so that the feet are always on the lowest part of the collider. However option 1 can cause some jank with being able to fit into places where the full collider doesn't fit. Finally I wanted to say, thanks for this project, making a good 3d character controller is a lot of work, I never managed mine to feel fully right, but this one feels pretty good.
@NickMaltbie
@NickMaltbie 10 місяців тому
Hey, thanks for the well thought out comment and response! For the animations, I imported them without a model to save space, as I mentioned in the video, I got the animations from Mixamo (www.mixamo.com/) but I created a ticket in the project github.com/nicholas-maltbie/OpenKCC/issues/215 for documenting how to create, modify, or add animations. I didn't consider when the avatar would be rotated away from the character, I have an existing issue for tracking the improvements for foot IK so I added it as a task to the project github.com/nicholas-maltbie/OpenKCC/issues/193 - account for player hip rotation instead of using the player forward for foot direction. For the jump animation and collider, I need to touch that up a bit more, I added a task for it in the existing ticket related to the character collider shape - github.com/nicholas-maltbie/OpenKCC/issues/210 If you have any other suggestions or comments for the project feel free to let me know or open a new issue or ticket! it might take me a while to address all the tickets because there are a lot of open ones. But the project is open source so feel free to add suggestions if you have any!
@ficolas2
@ficolas2 10 місяців тому
@@NickMaltbie Thanks for your reply! I did notice a few more things. There seems to be a bug where the player gets stuck on a falling animation while walking on normal terrain. I haven't researched much about this one tho, and I don't know if it's specific to some settings I'm using. Also, it would be nice if we could add animations for walking sideways, currently, using the forward walking animation for walking sideways is a big akward looking.
@NickMaltbie
@NickMaltbie 10 місяців тому
Hey, there is an animation for sideways walking (called strafing) and is included in the default animation controller :) For the getting stuck in terrain, that's part of this ticket for adding the skin width parameter - github.com/nicholas-maltbie/OpenKCC/issues/210 it's caused by the player being too close to the ground and physics computation getting stuck. Will take a bit of work to fully fix and not just patch over.
@ficolas2
@ficolas2 10 місяців тому
I just noticed, the falling animation bug seems to already be reported
@Omnivoid22
@Omnivoid22 Місяць тому
would have no Ik be the issue with my feet not staying in place on the ground in unity? even tho in the animation preveiw the feet stay on the ground and dont bob up and down during the animation?
@NickMaltbie
@NickMaltbie 5 днів тому
Yes, ik is originally a concept from animation and it’s often used in games to lock a player’s feet onto the ground and not interrupt existing animations for skinned mesh renderers in Unity
@Omnivoid22
@Omnivoid22 5 днів тому
@@NickMaltbie ok cool cuz i was wondering why tf it was doing that. Didnt now I had to add ik in unity itself. So i gues the rig ik has no effect on that and its just to move the mesh as needed but if i wanna keep em bound to the ground i have to add ik in unity?
@barterjke
@barterjke 7 днів тому
Not to diminish an educational/explorational part of the video, personally I think the achieved result doesn't look any good, it has a lot of Uncanny valley vibe. It explains why there are no 3d person platformer games with a realistic rigs. And why everyone who uses procedural animation are doing it for some silly cartoony games. And why most of the parkour games are 1st person. But the way, the problem with moving platform is usually resolved with setting a transform of the platform as a parent for the character, when he steps on it. It resolves some of the other problems with moving platforms, like boosting player up if he jumps off it. You can see that problem in Half-life 1, jumping in a elevator results in a shorter/longer jump depending on the direction in which the elevator is moving.
@NickMaltbie
@NickMaltbie 5 днів тому
Hey, thanks for the reply. I would agree that some IK leads to uncanny interactions and this can be seen in any procedural animation if you look hard enough. My implementation is very basic and just an attempt to keep the character’s feet locked to the ground when they aren’t supposed to be moving. Guiding the knee joints helps smooth out this uncanny feeling and I could add better smoothing for how the feet are locked to the ground or released for the animation. I don’t think I’ve covered my moving platform implementation. I want to avoid parenting it directly to the transform to avoid some types of errors that would be very complex to explain. It’s a good topic for future video :)
@kdawg717
@kdawg717 Місяць тому
I don't understand I've download the project from Git and it has nothing to do with anything covered in this video. I'm confused.
@NickMaltbie
@NickMaltbie 4 дні тому
See the humanoid FootIK class for details - nickmaltbie.com/OpenKCC/docs/api/nickmaltbie.OpenKCC.Animation.HumanoidFootIK.html It’s in the project, checkout the example scene and remember to download the LFS artifacts :)
@RaulLopez-rq6wh
@RaulLopez-rq6wh 6 годин тому
The mole video never came out
@zarodgaming1844
@zarodgaming1844 10 місяців тому
u didn't talk about performance 🤔 I stopped using them because of that even solutions on the asset store kinda lie about it. it's hell but a true god-send that doesn't use dots should come in the form of a determined baked library ... rather than a simulated runtime calculation for each character. It's truly awful tho, both to write AND THEN to populate with all kinds of animations.
@NickMaltbie
@NickMaltbie 10 місяців тому
I think with my solution it only adds two to four raycasts per character per physics update. Not too much of an addition but could definitely be optimized by adding a step to disable foot IK when a character is obscured or more than x units away from the camera. Disabling or enabling the foot IK is as simple as flipping a flag. I want to write a port of the project for DOTS as well, but that will take a bit of time to fully work out all the features. If you have any questions about the code feel free to let me know. The whole project is open source and I want to add some perf testing in the future as well, I might open an issue or ticket for that in the future.
@TheJungaBoon
@TheJungaBoon 9 місяців тому
Another trick I've seen in some games like Darksiders 2 is that they only enable foot IK when standing still. Since usually, the movements are fast enough when moving that it's not as noticeable
@FromFame
@FromFame 9 місяців тому
As interesting as this is, for my games I'd rather just animate stairs/jumping/turning/etc since I'm an animator more than a technical developer.
@kolupsy
@kolupsy 3 місяці тому
I also like doing as much as possible with animations but you can only cover so many cases and you will get limited accuracy. For consistent and proper foot placement it’s pretty much necessary to implement runtime IK like explained in the video. It’s about figuring out what tasks to solve in what way
@Sclaraidus
@Sclaraidus 10 місяців тому
Is it just me or does this guy sound a lot like Garbaj?
@NickMaltbie
@NickMaltbie 10 місяців тому
I've seen some of their content, they make some neat stuff too.
Making a Climbing Prototype in Unity in 48 Hours
11:10
Nick Maltbie
Переглядів 34 тис.
Why Stairs Suck in Games... and why they don't have to
11:24
Nick Maltbie
Переглядів 1,5 млн
Bro smelt it & passed out 😂 #comedy
00:10
MrTalalaa
Переглядів 7 млн
GADGETS VS HACKS || Random Useful Tools For your child #hacks #gadgets
00:35
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Переглядів 2,3 млн
Unity Basic Third Person Movement - 15 minute / 60fps
15:25
Canixel Arts™
Переглядів 17 тис.
I'm Switching from Unity to Godot and You Should Consider it as Well
7:07
An introduction to Shader Art Coding
22:40
kishimisu
Переглядів 881 тис.
What's The Deal With Procedural Animation?
11:24
Geat
Переглядів 26 тис.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Переглядів 1,3 млн
AI Animations with Unity's Muse Animate
7:03
Warped Imagination
Переглядів 3,8 тис.
Bro smelt it & passed out 😂 #comedy
00:10
MrTalalaa
Переглядів 7 млн