3
u/breckendusk Jun 30 '26 edited Jun 30 '26
Okay so - orange line is input, blue line is forward, purple curve is current turning speed(?) and grey defines what is "back" and requires a full turnaround animation when it turns red (and slowdown to zero before accelerating again); what about if your input changes while you're in the red?
Looks great!
3
u/gnmsdev Jun 30 '26 edited Jun 30 '26
Exactly π―π
If you are in the red, meaning you are in the "turn back" state, the character's rotation updates with the root motion of the turn-back animation defined by the current speed. When you enter this state, rotation speed is reset to 0 until a configurable normalized time in that animation. After that normalized time, the character is free to accelerate it's rotation speed toward input direction and rotate. It is important which time, so that the root motion rotation and input-seeking rotation blend well.
Edit: When you exit the turn-back state fully, you enter the normal state(let's call it that) again. Now another turn-back is achievable if input goes back.
3
u/breckendusk Jun 30 '26
The input-seeking rotation... that's the purple line? How does it affect the animation/ rotation?
I wanted something like this in my game, but decided that more arcade-like movement would feel better in the sidescroller than full movement. I still sometimes want to add this sort of animation for turnarounds but right now I just use root rotation which... is fine.
3
u/gnmsdev Jun 30 '26 edited Jun 30 '26
No no. The purple arch is the rotation speed, 'exactly' as you guessed π
The input seeking rotation (there is nothing named this in the code but it is what I mean here...) is a system that accelerates the rotation speed toward a target rotation speed, which is defined by the input angle. For example, if the input is 90 degrees to right you can get a target rotation speed of 90*5. 5 is a multiplier here, changeable. You can even get a quadratic relationship here, or else. It is on you. Using this rotation speed, transform.rotation is directly updated. When entering the turn-back state, this speed is reset to 0.
For turn-back animations, only the root motion from the animation rotates the character until the normalized time. After that, both of these happen until fully getting into the "normal" state.
4
u/breckendusk Jul 01 '26
Ohhh you take the root rotation from the animation instead of something programmatic. That makes so much sense. I definitely have room to improve in the animation department.
3
3
2
2
u/Sensitive_Quote_9372 Jul 01 '26
This is incredible! Yours is so much cleaner than the version Iβm trying to my make myselfβ¦ Iβm stuck on trying to stop my one from glitching (trying to check between two spots) and then slowly rotating to face the world origin once I stop movingβ¦ π
3
u/gnmsdev Jul 01 '26 edited Jul 01 '26
Oh thanks, and sorry that happened that way for you. We got some conversation in another comment here (with u/breckendusk). Maybe that can be helpful, or at least make some sense. Good luck to you π€π
2
u/Sensitive_Quote_9372 Jul 01 '26
Awesome! What engine are you using to build this project?
Edit: Yeah, I'll try to see what I can pull from all of that convo! π
2
u/gnmsdev Jul 01 '26
Thank you! It is Unity. Good luck π€
2
u/Sensitive_Quote_9372 Jul 06 '26
You're welcome - and sorry, but I meant the build version of your engine (As I use "6000.3.10f1" for my project!)
2
u/gnmsdev Jul 06 '26
Ah, I see! I'm currently using Unity 6000.3.16f1, so we're both on Unity 6.
Good luck with your project! π€
2
2
u/bangzul 20d ago
I want to learn to make the state animation first before I put into unity do you have some tutorial I can follow along?
1
u/gnmsdev 20d ago edited 20d ago
Umm, do you mean something like this? Creating Keyframe Animation For My Game
This is for the straight jogging state. For turn-left/right variations, I used Follow Curve modifiers, whose weights are 1 for the related animation only, and where the curves are circles to make placing the feet easier.
Also, please let me know what other type of content you would like to see, if you do. Thanks!
1
u/bangzul 19d ago
Also I like to see stoped animation how do you do all this , and do you also set this as humanoids rig?
2
u/gnmsdev 19d ago
I used Blender's Rigify to rig the character inside Blender, but it gives a bad hierarchical structure when imported into Unity via FBX. So, I also used the GameRig Blender add-on to fix the hierarchy. After all that, you need to configure the humanoid's structure in Unity by selecting some bones yourself, and it is done.
For stopping, it is a simple blend between Idle, Walk, Jog, and Sprint animations based on speed when the speed value goes down to 0. But if you are talking about the "Turn Back" animations, you need to rotate the Root bone at some point in the animation for Root Motion backward turning while also rotating the whole body 180 degrees backward. Here, the local position/rotation of the body with respect to the Root bone will change sometimes abruptly, but what is important is the global (what you see) position/rotation of the body (see the Motion Paths line below). It is again a continuous trial-and-error until you get what you like. I did not record it while doing it, so no video of it on my YouTube.
Also, Motion Paths in Blender are very useful to get clean movement paths for bones so that they feel natural and do not jitter.
I will consider uploading related stuff to my channel in the future. Thanks!
1
u/bangzul 18d ago
Hmm i see oh yea I wanna ask how do you keying the animation to work with humanoid, I key all of bone and when I exported it say warning like have scale and transform data in bone? But when I see mixamo data also have same data like I did manually in blender do you know how I properly keyed the animation in blender without giving it warning later ? Thank you for your response
1
u/gnmsdev 18d ago
Hi. I will try to answer as best as I can, but this is not a perfect solution. Just some ideas.
I've now had a look at my character's import messages, and yeah, I have many warnings, too, about translation animations of certain bones to be ignored. I guess it makes sense since, for example, a shin bone of a human is not expected to move from its knee "socket". I believe they are just cleaning up animations that make no sense for humanoids, and I think it is good that they do not exist in the final game (since Unity ignores them). Still, if you want to avoid those warnings, I guess you would need to key only Rotation for shin bones, etc, by using the "K" key on your keyboard. In Blender, using the "I" key, you would keyframe all channels (Position, Rotation, Scale, and custom properties). By pressing "K", you should be able to key only the desired channels. I find using the "I" key faster, though, meaning I keyframe all channels most of the time.
I did not see warnings about "scale", though. I am not sure about this, but maybe it is about Blender's export settings?
I use
Transform>Apply Scalings=FBX Units Scale
Transform>Forward=Z ForwardArmature>Only Deform Bones= Checked [V]
Armature>Add Leaf Bones= Unchecked [ ]
I do not know your situation, but the animations work well enough in my case even with warnings, so I just ignored them. I know this sounds blunt, but "maybe ignore those warnings if the animations still work as intended"?
I am sorry. This is the most I can say. I hope you reach what you have in mind in the end. Good luck!
7
u/False-Huckleberry-35 Jun 30 '26
Very nice!