- Home /
2D Animation position translation
I've been searching for a simple solution for this but couldn't find an solid answer one way or another.
I have a sprite. I have an animation that moves the sprite in a direction.
I would like to be able to loop this animation and have the sprite play each loop at the end of the last one instead of reseting to the start location at the beginning of every loop.
I've put the sprite into a anchor game object that will update via script the position of the object to match that of the sprite at the end of the animation. However due to the update timing it's not always accurate, the callback is hit before the animation updates.
I've created a empty .fbx object with a single boon to act as the avatar with a root bone, but that did not seem to improve anything.
This seems like something that should be pretty common but I've have no luck with searching for an answer.
Is it problem regarding animation playing at current position only?
Correct, it doesn't update the transform automatically.
I was hoping there was a way to do this without adding an additional script to update a position on a parent object with an AnimationEvent callback since that solution is clunky especially if the animation changes while playing which might skip over an event.
Ideally I'd like to have the transform updated while the animation plays, which I believe is a job for 'root motion' but haven't been able to get it setup in such a way that it would work like that.
I've tried it with both 'root motion' check and unchecked didn't get any results I wanted. $$anonymous$$y data might be setup incorrectly but as mentioned above, I've tried:
just a sprite
a sprite in an dummy game object
a sprite in a dummy object with a bone
a sprite in a dummy object with a bone inside another dummy object.
$$anonymous$$ust be missing something here.
Your answer
Follow this Question
Related Questions
My animation barely moves with root motion. 1 Answer
Root motion lost in transitions 1 Answer
Snapping Child to Root after Animation 2 Answers
"Double transform" on 2D hitboxes when root motion is enabled 0 Answers
2D Animation does not start 1 Answer