Move 2D sprite to multiple destinations similar to animation

Hi. I’m totally new to Unity & coding. I want to start experimenting, but looking around other topics, I only found semi-relevent stuff, so I’m posting this specific question.

I’m trying to take a static 2D sprite & make it so that it moves along a path in specific frames, extremely fast, to its destination & back again within a few frames, on key press.

Something like: Idle → destination 1, 2, 3, 4 then retracting back. With 1 single keypress.


i would animate it

  1. add sprite to the scene
  2. add animator on the sprite
  3. in project window create animator controller asset and attach it to animator’s controller slot
  4. in project window create animation asset
  5. select the sprite, open animator window and drag the animation asset into the window
  6. open animation window, select the sprite and animate it (if you want animation in relative space then you need to have the sprite in container - empty gameobject
  7. create component where you will on keypress play that animation

other possibility is to make the procedural movement using update, where on the keypress you’ll select destination, when it reaches destination yoe select another until you are at the last, then returning back

or you can use some tweening asset like iTween Unity Asset Store - The Best Assets for Game Making