Hi, I am new to Unity and I am stuck on an 2D sprite animation issue that is driving me a bit crazy.
So I have a game object (player) with a controller script which moves it around with associated animations for a some movements like idle, run, jump, double jump…however in the animation tab where you can edit the frames and add properties, the transform property completely breaks my game object when I run the game simulation. The game object (player) is repositioned to a higher location within the scene and doesn’t move at all no matter what I do.
I just wanted to manually adjust the y position of some of the sprite sheet frame by frame but this is globally affecting the game object in the scene.
I should mention I did some research to try and figure out the issue myself before posting here and I found out that adding an empty parent object allows the child (player game object in this case) to use local coordinates. You can see this is the uploaded image too. However this is still not working for me when animating the transform property.
This is just driving me nuts. Please help!
Thanks in advance.
I hate this animator system of unity, I think it is too complicated for 2d sprite animation
Finally, I implemented a simple sprite frame animation system by myself
But adding an empty parent to the player should make it move in local coordinates, is there a problem?
By the way in general you probably don’t want to use transofm animations to make jumps. You should simply play frame animations and let the physics system control the movement/jumping
Hi Urada, thanks for the reply!!! I appreciate any help! Just for brevity I am gonna copy and paste some points you made and reply to those directly (hope that's cool) 1 - "...adding an empty parent to the player should make it move in local coordinates" I did that too - as shown in the image. In my case its called "PlayerWrapper" and the actual animation is on the game object called "Player" which is a child of "PlayerWrapper". In my case it doesnt seem to help the localizations of the position.
2 - "...in general you probably don’t want to use transofm animations to make jumps" This is true -- normally I would just use the sprite frames but I'm not really using the transforms for the jumps. I just want to manually reposition the individual frames a bit up or down because the pivot point for these frames are at the "bottom center" of each frame and it makes the jump animation looks off. You would think if you key frame a new position of a frame it should be moving to that position and not break everything -- it makes no sense and I am hoping someone can explain to me !!!
For the transform problem, your screenshot is incomplete, have you really set the keyframe of the position? You can’t simply modify that value
By the way, the transform.poition here is actually localPosition, I don’t know why unity insists on marking it as position in the inspector and animator
And if you use this method to adjust the center point of the image, the final behavior may not be what you expect
The animator will automatically interpolate between transform.position keyframes, but you can edit the animation curve to turn this off.
There are also some additional side effects. During the animation, the player’s transform will be taken over by the animator. During this period, you will not be able to control the player.transform with code, and Warrper’s transform will not be affected.
For the pivot, you can manually adjust the pivot of each sprite in the sprite editor. Another common method is to export a larger picture than the actual sprite, and directly integrate the sprite pixels with misaligned pivots in the art tool Move it up or down, and eventually all images will have the same pivot when exporting.
The above texts are all translated by translation software, if you have any questions, please tell me directly
Hi Urada, thanks for the reply!!! I appreciate any help! Just for brevity I am gonna copy and paste some points you made and reply to those directly (hope that's cool) 1 - "...adding an empty parent to the player should make it move in local coordinates" I did that too - as shown in the image. In my case its called "PlayerWrapper" and the actual animation is on the game object called "Player" which is a child of "PlayerWrapper". In my case it doesnt seem to help the localizations of the position.
– Stankyfist2 - "...in general you probably don’t want to use transofm animations to make jumps" This is true -- normally I would just use the sprite frames but I'm not really using the transforms for the jumps. I just want to manually reposition the individual frames a bit up or down because the pivot point for these frames are at the "bottom center" of each frame and it makes the jump animation looks off. You would think if you key frame a new position of a frame it should be moving to that position and not break everything -- it makes no sense and I am hoping someone can explain to me !!!
– Stankyfist