Jump to content
• ### What is your GameDev Story?

• Advertisement

# Algorithm Matching the speeds of the blended clips in a 2D blendspace

## Recommended Posts

Sup dudes and dudettes!

I'm in the process of implementing an animation state machine and am currently making a 2D blendspace state for it.
I think I've figured out how to blend the different clips together given an [x,y] coordinate but I have one problem I'm not sure how to solve; matching the different blended clips' animation speed.

Say you have your run-o-the-mill twin-stick character locomotion blendspace, where max Y, zero X means running straight forward, and max Y, max X (in either direction) means running at an angle (thus blending run_forward with run_strafe).
In this case the animations' speed probably match, so there's no worry. However, say I'm halfway up Y, meaning I'm "jogging", in the sense I'm halfway between walk_forward and run_forward, and my X is at some arbitrary point.
How would I blend these animations together so that their speeds match? Would it be as simple as 'lerping' the animation speed of the walk towards the speed of the run and scaling the speeds of all the clips to match this speed?

Sorry if the question is poorly written.

#### Share this post

##### Share on other sites
Advertisement

If I was blending between several loops (walk, run etc) I'd make them all over the same number of frames, so they stay in sync. Then as you say just a simple lerp between desired fps for each animation. Probably with some interplay for setting speed from code to match animation to movement and prevent foot sliding.

#### Share this post

##### Share on other sites
39 minutes ago, lawnjelly said:

If I was blending between several loops (walk, run etc) I'd make them all over the same number of frames, so they stay in sync. Then ...

I'm sure that would work but I'm not a big fan of forcing faster clips to have more frames. We're under pretty tight memory constraints for this project so every meg counts.
Perhaps one could scale the speed of the blended clips depending on the blend factor?
E.g. if you have your run with 20 frames and your walk with 30, and the blendfactor is 0.5 you could scale the speed of the run down and the walk speed up so they sync halfway (since the blendfactor is 0.5)

#### Share this post

##### Share on other sites
4 minutes ago, GreenGodDiary said:

I'm sure that would work but I'm not a big fan of forcing faster clips to have more frames. We're under pretty tight memory constraints for this project so every meg counts.
Perhaps one could scale the speed of the blended clips depending on the blend factor?
E.g. if you have your run with 20 frames and your walk with 30, and the blendfactor is 0.5 you could scale the speed of the run down and the walk speed up so they sync halfway (since the blendfactor is 0.5)

Sure, as long as you make sure you are not accumulating any e.g. float error.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 28
• 16
• 10
• 10
• 11
• Advertisement
• ### Forum Statistics

• Total Topics
634107
• Total Posts
3015550
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!