I encountered this problem in the recent wildjam, I have a player/enemy in topdown perspective and I want to quickly and visually create an animation. I have now managed to create a minimal setup/example that works (Pic provided) but it sounds way too complicated and I was wondering if there is a better way to implement this.
This is the problems and my thought process and solutions I came up with
- animating the position of the root node doesn't work because that's global coordinates, creating a sub node to animate fixed that.
- changing the player direction doesn't affect the repositioning that happens in animation player. I created a third node that allowed me to do that, I named the second one LocalRotation and the third one LocalPosition. if localRotation has 30 degree rotation (aka the player looks at 30 degrees) and an animation of localPosition moves by x=100 then that transform will be rotated as well since it's a child node of localRotation.
- Then certain things such as sprites shouldn't be rotated plainly (for example a 4 direction sprite only has 4 angles drawn) so once again created 2 more nodes, 1 for things that should get rotated and 1 for things that shouldn't, NoRotation constantly counter rotates.
- To keep the object from going through walls the collider also constantly has to update to the LocalPosition.position and everything gets re-zeroed after an animation gets canceled or finishes (for example LocalPosition = (10,0) -> (0,0) and root becomes (+10,0)). So this inserts a complexity of always looking after any animation and cleaning its changes in rotation and position (pic 2 provided). To be expected but I am also never able to use sprites in animations but rather change variables and create @tool scripts so that I can see the sprite changes during animations.
If only there was a way to make animations in local coordinates and with some rotation variable in mind..