• News

• Industries

• Learning & Support

• Community

• Marketplace

# Mess with 2d Animation BlendSpace/ CCalculating wrong direction

Hey guys!

I have a problem with my first person character.
I have a 2D Blendspace you’ll see below.
The main problem is, that the direction won’t set correctly if my character is moving. If I stand still, the direction value goes up to 180 and down to -180.
When I start walking now and change my direction at the same time the direction value can just go up to 15 and down to -15.
Another problem is, that when I walk backwards the direction “stuck” at 175 and -175.
You can see my Animation Blueprint too.
All those blie lines you can see are coming out of the “Try Get Pawn Owner” function.

Sorry for my Blueprints - I know they are a mess I’m just learning

I hope you can help me with this

Best regards

Lutz Gooren

instead of using speed and angle as the 2d axes for your blendspace Id use vector magnitude (as I call it).
So You have vector x which is generally forwards and backwards and vector y which is left and rig.
Then you can set up a circular pattern instead of a rectangular one. The axes then go from -maxSpeed to +maxSpeed in x and y.
Here what I do is to have a float speedMode variable that dictates the character maxWalkSpeed, acceleration, brakingFrictionFactor, etc. 0 is standing still, 1 is walking, 2 is running, 3 is sprinting.
So then I have to get the relative direction of the velocity against the actor using the dotProduct of the velocity vector vs the actor forward and actor right vectors. That then I multiply by my speedMode variable and feed it into the blendspace I have set up with those x and y axis.

• the ability to scale as you need by just adding circular rings of anim pins if needed. A speed/angle approach also offers this, but you have duplicate pins at 180 and -180.
• no interpolation issue when going from diagonal backwards left to diagonal backwards right. Depending on how you set up your variable that could basically make your angle go from -165 or whatever to 165 over 0 instead of over -180 and flip. That basically gives you a full circle while you just changed a few degrees crossing -180/180.

Where I have to set this up? In the animation blueprint or in the blendspace? Sorry -> I’m working for 7 hours now

Maybe you can upload a screenshot or something else ?

Yeah ill upload a few setup screenshots or a video of this when I get home later.

Thank you mate!

Okaaay… I just ried your solution but I think I messed it up too I will post a video shortly

Here you can see what I did ^^: https://youtu.be/6PV83J0_0rU

Same thing with the circular pattern

edit, just noticed the video link there, sec watching…
alright…
cant quite tell whats going on… in your video, at 0:13, it looks like that setup with the dotproducts is a bit wired, can you post a big screenshot of it?

Okay! I just set the speedMode manualy to 2.3 - Now it’s working how I want it ^^ Thanks for your help!

Hey! Here is the screenshot which you asked for:

I edited it back to the version with the vector break.

The walking backwards animations are a little bit slow, but I’m trying to fix this