I want to flip my 2D character (asymmetric) from right to left using the animator in Unity3D
I have the sprite sheet with both left and right sprites and I did a controller with the animations facing right, now I need to flip the animations to the other side
Done:
Sprite sheet with both animations left and right
Animation controller with animations facing right
Goal:
Make my character change animations facig right to facing left and viceversa
I'm aware of the code to change the local scale, but I'm not interested in changing scale, I'm looking for a way to flip the animation
Thanks
You can flip the animations changing the x/y scale from positive to negative. Why you are not interest in changing the scale? You can flip the animations with this method.
Sorry for my English and good luck.
Related
So I did an attack animation in the program Aseprite and everything was fine with the animation, but when I put in inside the animator in unity the character changes position.
Here's the images, first one is a gif with the animation running as I want, and then the before and after of the animation in Unity.
I know it's small but I hope you can see
This is because it's setting the center point at the location, and the gif is wider than the standard player image, you will need to offset to compensate.
So I just sliced the sprites again but with the pivot to the left instead of center, and then adjusted the Collider. It seems to work. Not sure if it's the perfect way though.
This might be a stupid question but I'm stuck and can't get passed it. I'm making a isometric game and I have my map built using tiles, I just followed this tutorial to build the map, http://www.binpress.com/tutorial/creating-a-city-building-game-with-sfml/137. But now I don't know how to add character sprites. Do I have to add these sprites using tiles as well or do I just draw the the sprites into position of the screen. Any help would be much appreciated.
As far as I can tell from the engine, just follow the "Textures and Animations" guide and draw the Animation to the screen after you have drawn the tiles. This isn't a complicated engine, so you are only working with 2D sprites being drawn to the screen (the 3D effect is merely tricks of painter's algorithm to make it work...there is no z-axis from what the tutorial indicates)
The depth is done by the order of tile rendering
The same goes for objects,players,etc... Let assume plane XY is parallel with the ground and Z axis is the altitude. Then your grid would be something like this (assuming diamond shape layout):
Order of rendering
You have to handle object,players and stuff sprites in the same way as tiles (and in the same time). so you should render all cells in specific order dependent on your grid layout and sprite combination equation. If your sprites can overwrite already rendered stuff then you should render from the most distant tiles to the closest to the "camera". In that case the blue direction arrow on above image is correct and Z axis should be increasing in the most inner loop.
So now if you got any object,player or stuff placed in cell (x,y,z) then you should render it directly after the cell (x,y,z) was rendered prior to rendering any other cell.
To speed up is a good idea to have objects and players in your tile map as a cell. But for that you have to have the tiles in the right manner and also your map representations must be capable of doing so.
I'm using sprites for an animated menu in my game.
I tried two methods:
Image Renderer: Replacing the image per frame with the sprite slice in the animation window
Sprite Renderer: Same method
I'm playing the sprite animation with no loop then rotating the transform on the z-axis.
The problem is that with the image the Screen Space overlay works well but the rotation of the transform causes the sprite to look glitchy and rough. With the sprite renderer however the Screen Space must be put to Camera and the sprites get placed between other assets in the world.
Example: http://postimg.org/image/436q9jvax/
Is there a way to either fix the roughness on the rotation using image or force the Camera Screen Space on top? My only concern with the 2nd option would be in relation to responsiveness for multiple devices.
The easiest fix was to apply "sorting layers" to the canvas with the sprite renderers on to keep it on top.
I did however incorporate #beuzel's idea about separate cameras in the end and opted for 2D sprites with physics instead of a 3D rendered animation on canvas.
http://postimg.org/image/6qmtiirb9/
Thanks for making the good sample. A fix for the menu intersecting the world is using a seperate camera for the GUI layer. The rough animation might be a pixel perfect setting in the sprite rendering (just guessing).
I don't have enough reputation points to write this as a comment.
I made an animator for my Player Character, I have 2 differents animations.
When I play only one, nothing, it's cool, the character is doing the animation.
OwnAnimator.SetBool("running", true);
But when I have multiple animation (2), in my AnimatorController, the player goes under the floor instantly at the runtime O_O.
Please someone can help me ? :)
What is your second animation? Since animations can affect the transform position it is possible that your animation changes the Y-axis of the transform.
i'm already checked official Unity 4.3 example project, and there they use
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
This works pretty well, but. But i'm encountered an trouble, not sure this trouble with this Flip or with something else.
I'm use Animator to animate my characters, i have Attack animation, which in addition to the sprite animation also move character's Hand, which can carry the Weapon. Problem is when i flip the character to opposite direction Hand will move wrong (not as planned), which is wrong. (video below will be more descriptive)
I discovered that this problem occure only if i modify the Hand's rotation in animation, so if i works only with .position this works well, but i need the rotation!
What is best way to get this work?
Here the youtube video: http://youtu.be/qpMK2gRgDz8
At video i show animation without rotation uses, hand moves correct. But next i show it with rotation, as you can see when character turned right this works well, but when left, its completely wrong.
What you want to do cannot be done with scaling cause scaling does not change the rotation of the object and so the forward vector remains the same. You must create double sided objects and just rorate them 180 degrees or you can ue a shader that draws a polygon even when its normal vector is against the camera.