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
- add sprite to the scene
- add animator on the sprite
- in project window create animator controller asset and attach it to animator’s controller slot
- in project window create animation asset
- select the sprite, open animator window and drag the animation asset into the window
- 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
- create component where you will on keypress play that animation http://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html
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