Hi. I have been trying for about two months to find a way to implement a procedural leaning system which will work alongside an AnimationTree. The idea is that I would like to take the amount of camera tilt (distance that the camera has rotated away from the horizon point) and apply that rotation equally to various bones (spine, neck etc). I have included a simplified version of the code that I am applying to each of the relevant bones below. Everything I have tried so far has had no effect whatsoever on the bones; the character animations always take precedence and there doesn’t seem to be any built-in way in Godot to achieve procedural leaning, nor any useful documentation for any feature related to it. I have tried to apply the rotation at various points in the code (notification callback, calldeferred etc) with no change. AI is useless and has been sending me round in circles without actually understanding the problem. To clarify: by procedural leaning, I mean that the character’s top half should bend forward or backwards when the third-person camera tilts up or down.
All I want to do is apply additional rotation per frame (on top of the animation rotation) for certain bones without it applying additively. That’s it. This should be very simple.
I’m at my whits end; I have coded this game almost from scratch so far with no real issues for over 6 years, and this is one of the few cases where I actually need to use built-in engine functionality and Godot has well and truly dropped the ball (I should have just made my own engine, it would have been easier).
So my question is: has anyone managed to implement procedural leaning in Godot before? Are there any tutorials (I can’t find any for version 4x)? Does anyone have any helpful insights?
The only reference I can come up to for the term “procedural leaning” is for Skyrim mods. Just FYI, it is not a term outside that community. It sound like a clever play on words someone made up based on “procedural learning”.
Yup. AI is a spicy autocomplete machine. It doesn’t not understand anything. It can only regurgitate things - but it will never tell you it does not know. Not only were you trying to use an LLM for Godot (at which they are notoriously bad with Godot in particular), you were trying to get it to tell you how to do something that isn’t a real term (“procedural leaning”). So it was probably giving you Unity 5 answers that it tried to make into Godot answers. It probably combined these with “procedural learning” which is a thing. Combine that with LLMs combine code examples from Godot 2, 3 and 4, as well as functions that do not exist, and you see why you were having a problem.
Save your current AnimationTreeRoot
Add a Lean animation.
Create an AnimationNodeBlendTree as your AnimationTree’s root.
Add a Blend2 to the AnimationNodeBlendTree
Have your existing StateMachine connect to the Blend2“in” Input.
Add an Animation to the AnimationNodeBlendTree
Populate the Animation with your new Lean animation.
Have your Animation connect to the Blend2“blend” Input.
Connect the Blend2’s Output to the Output node.
Click Edit Filters on the Blend2 node.
Check the Enable Filtering checkbox.
Select which bones you want affected by the bending - only those bones will be affected. The rest will use whatever animation you’re running in the StateMachine.
Click the OK button.
Add code in your player controller so that when you look up or down, a blend amount between 0.0 and 1.0 is set on the Blend2 node.
You need to implement the modifications after the AnimationTree has been processed. You can use the AnimationMixer.mixer_applied signal to know when it’s done.
But it would be better if you use any of the multiple SkeletonModifier3D nodes to accomplish what you need. For example:
If you still want to do it yourself then you can check this article for a more in depth explanation on how the SkeletonModifier3D stack is implemented:
Hi, sorry for the radio-silence, I was ill for a while and wasn’t working on anything code-related. Thanks for the replies, they’ve confirmed my suspicions and given me some new ideas to try.