In this short video I will show you how to easily achieve realistic looking foot placement for your characters in Godot 3.2. This solution is very simple, but it may be sufficient for many projects.
Thank you so much for this tutorial, I was looking for a foot IK tutorial for months. Zylann made a demo video but I was too inexperienced to figure it out. This tutorial is more than welcomed!
Hi, if I remember correctly, the thing that Zylann made was a totally procedural approach without animation blending. Probably it looks better and is more professional. My solution only sticks foots to ground in predefined way :D However it works mostly ok and is extremely easy.
I think your main issue why it looks "janky" is model itself or your rig was setup incorrectly. You can see it clearly around calf area. Calf is rotated towards outside while foot remains straight. It is very noticable when character is standing still.
Hi! The main reason it looks like that it's because I simplified a "look at" vector for feets in IK system. Right now it basically takes a front vector of character and copy it. For better results we should copy other bone orientation in XZ axis, or we should store feet orientation in animation resource somehow (maybe just by rotating "interpolation" Position3D node and adding this value in code). It's definitely on my todo list. For the sake of this video I wanted the code to be really simple, I think that anyone can improve it from here.
@@wojtek_pe if that is the case in my opinion easiest way would be to combine IK with FK. Instead appling rotation to foot, apply it to calf bone. It should then rotate foot together with calf bone. At least if Godot bone system works 1:1 how Blender bone system works. Another idea would be to move pool target for knee to face character forward vector (this would need to be tested to see if it will be janky).
@@BrainAirways Hi, I was experimenting with some ideas but in the end I probably try to add another position 3d for magnet value. Actually the skeleton is something like that: Hips -> leftUpLeg -> LeftLeg -> LeftFoot -> LeftToeBase, I can't modify Hips from both Ik systems and modifing ony LeftUpLeg and LeftLeg doesn't give desired result . I was hoping that somehow I could read original bone position and orientation form animation in Godot and just override it slightly but it doesn't seem that this is possible. The second solution you proposed is actually the thing I am showing on the video. It seems sometimes weird, especially in a idle position because rotation of bones inside ik system arent modified beside the tip bone. I will experiment with more and hopefully I will have something to show on my next devlog
thanks man! I watched a similar approach using Unity. I am trying to inference the feet movement using the velocity of each foot and also placing the hips so the boddy adjust to steps correctly. This approach is very handy neverless.
Hi! This is really a basic approach which could be done in 15 minutes, so of course it's lacking many nice features. If you made something more sophisticated I would gladly hear about it! I didn't find anything on YT about IK foot system for Godot so I made this simple video. I am also a beginner in this topic.
Excellent tutorial, but I can't read the character.gd script at all on my monitor. You might want to either increase font size while recording or link to a git repo for your scripts in these videos
When we enable the magnet I get a very weak effect when I move the target container node. What do we set the magnet "Z" based on and is that what is causing this issue?
Hi, the magnet value basically describes how your joint is rotating. In my case, it just sets the direction the knee should be bent to. So it acts as a "magnet" for a knee. Without it the joint will act weird. Proper value really depends on your model. If you have it rotated other way than mine or your scale is way bigger than value "10" at "Z" will be bad. Just place your target container node in some place where your leg should be able to be positioned. Than experiment with different magnet values. At some point it should looks natural in every position of target container. You should also check if you selected proper bones for SkeletonIK. I am using mixamo rig with Godot Game Tools addod for Blender.
@@wojtek_pe I have just seen this reply and appreciate the information, it is extremely helpful to me! It was on a custom rig and model with its own ik so it makes sense the scaling could be very different. I will look into what mixamo outputs closely and see if I can get a nice result. Cheers! :)
so on trying to implement it my characters legs go up. How did you tweak those parameters(minmax_interpolation, foot_offset, ik_raycastheight)? I saw my characters legs are more sensitive when moving the target_left and target_right. Any thoughts on this?
Hi, I am not sure why your character legs go up, maybe you didn't setup your raycast length properly, so there is bad collision? You should check ik_raycastheight parameter, it must be lower than your raycast length. As for the parameters tweaking. "minmax_interpolation" - I am using it for clamping. Minimum interpolation should be left around 0.03 because there is bug? in Godot. Not sure why but if you set it 0 your animation will stop instead being used 100%. As for maximum value you could use anything you want between min value and 1, I prefer to set it a little bit lower than 1, but you can limit also in your animation graphs (by setting value other than 1). I do not recommend setting it as 1.0 actually because it's looks "sticky", especially for running animations. "foot offset" gives you ability to manipulate raycast calculated height, sometimes it's a little bit off, so your foot is always in ground or in the air after IK. "ik raycastheight" moves a raycast up above the foot by this value it's useful when you want to detect not only lower terrain by also anything higher than your foot. As for sensitivity of IK depending on target position, I saw that too in this basic script, I set my targets a little bit back to my character. In my "production" script I am actually using another bone attachments for knees to setup as magnets, and I am using a basis of foot attachment for proper front foot orientation right now. Not sure what fixes this problem, but I cannot reproduce it right now.
@@Velsia Well, code IS copyrighted. Even that on stackoverflow. You are not allowed to use it however you like. See ToS. But most people don't care about these rules and chances you get sued are negligible. Its more of an ehtical / moral issue when you don't abide by the rules.
Hi, to be honest I don't remember how bad was default editor, I use vs code in my daily work so I am used to it. Integration is pretty easy, there is a tutorial on youtube by Gamefromscratch. As for benefits, I think it's easier to manage multiple files in a tree comparing to a list in built in editor (if it didn't change). There is also pretty nice autocomplete, and auto formatter. Also there is a lot of plugins for vs code not directly related to gdscript.
@@wojtek_pe Well I think uaing visual studio code is advantageous only if you jave dual monitors or a very large monitor as you don't have to constantly switch between the script editor and the scene editor. But if you work with only a single monitor then it is of no advantage or may even be disadvantageous since visual studio will use additional resources.
@@ChrisD__ You actually get autocomplete for nodes if you type variable types for every node. Ever since I came to know about it, I began to static type GDScript and now I always get autocomplete for every node.
Hi, you should check docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html If you are a software developer it's similar to python so it's really easy to learn. Just start doing some games with godot and you will find it natural to use.