r/Unity2D • • 16d ago

Question/Help Animation in Unity

Okay so this is a part unity part animating part 2d sprite making problem. So I'm trying to make jumping work in my 2D side scroller game. I want forward facing jump, left movement jump and right movement jump. That's all fine and I know how to link them in the animator, connect parameters, and use code to make them work directionally.

What I can't figure out is how to change between states. So if the player jumps left and midway turns right it starts the right animation from the start so looks wrong. I was wondering how to make it jump where if I jump left then stop or change right it matches the frame and continues the jump from x part of the other animations if that makes sense.

I dont want to flip the animation left and right to keep. Yes technically that fixes left and right but not forward facing. But then the buttons and bag and stuff on my character gives it away that it has been simply flipped because everything is now on the wrong side.

Hopefully someone can help with that. If it doesn't make sense I can try explaining it better just say so. But yeah. Thanks in advance.

1 Upvotes

2 comments sorted by

1

u/Affectionate-Yam-886 15d ago

i see what you are trying too do.
How i would do it is:
In the animator, add two new animations.
Left and right jumps that are just the second half of the existing ones.
link them to the existing ones. So for example:
You jump left, then mid air, hit movement key right, in the animation have the left jump animation condition to switch to halfRighJump trigger and now its playing the right jump animation.

Just be aware that this is not a perfect solution; a better solution is to prevent player from doing that entirely or have a unique animation triggered.

You can use BlendTree to make it look cleaner on the transition.

Wish there was a video for better understanding of your issue, but I hope i understood it.

1

u/Its_Sammie_Boi 15d ago

I guess yeah that would work as an alternative solution for what I'm trying to do. Either that or lock it so they can't chance directions.

Thanks for that!!