can i animate the transform with code?

so i’m making a turn based RPG and i want the character to dash up to an enemy, attack, then dash back.

The problem is i don’t know which position the character will be in, or the target enemy, and i don’t want to make like 18 animations for every single character.

So is there a way to get the enemies position, take away 50 from the x axis and then plug it into the animation key frame?

Or if there’s a better way to do it that would also be cool, thank you.

There are multiple ways of doing something like this. The way I would do it is to create a coroutine where I play the animation. Moving the player can be done with tweening. While you could write your own tweening system it can be easier to use a tweening library such as LeanTween or DOTween (they’re both free). In the coroutine, you could change the character sprite/animation (if you want animation), tween the position to dash, play an attacking animation from the animator, and then tween back the position. This way you can use the animator for character animation and tweening for moving.