How to make a smooth combat system

Hey, I was wondering this same thing a few months ago, and from what I saw it’s best to use animation weights. Each animation has a weight, and it determines how the overwrite other animations.

For instance, if animation0 had a weight of 0 and was playing, and animation1 had a weight of 1 and then you played it while animation0 was playing, animation1 would overwrite animation0.

If animation0 and animation1 had weights of 0.5, they would blend together, and the average position of the two animations would be the result.

A great way to think about this is the following. Let’s say we have 2 animations, in the first one the left arm has a rotation of 90, in animation 2 the left arm has a rotation of 0. If both animations have weights of 0.5, the arm would be at a rotation of 45 degrees. However, if animation 1 had a weight of 0.75, and 2 had 0.25, the arms rotation would be at 67.5 degrees.

This weight system also does not have to be limited to 2 animations, you can play as many as you want and have them all influence the output as long as the weight of each anim is > 0.

A good way to transition between animations is with lerping. Let’s say the player is walking, and then they punch. We would want to have the walk animation at a weight of 1, and the punch at 0. Then, you can lerp the walk down to 0, and the punch up to 1. As the character starts putting their arm down again, you can lerp the walk back to 1 and the punch back to 0.

Below I will add some great resources for animation weights.

https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/AdjustWeight

https://devforum.roblox.com/t/how-do-i-use-animation-weight/313047/2

if you have any more questions, feel free to reply. Hope this helps you!

8 Likes