Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Need help with beginner animation

Discussion in 'Animation' started by Delta935, Jun 11, 2019.

  1. Delta935

    Delta935

    Joined:
    Jun 8, 2019
    Posts:
    3
    Hello everyone, I am an absolute beginner to Unity and currently learning with some tutorials (Ruby 2D's adventure : https://learn.unity.com/tutorial/sprite-animation (part 5))

    I have a problem with the animation of the enemy : when moving to the left the enemy has the 'movingRight' animation. 'movingLeft' is okay but it is not the one 'played' when moving to the left. I don't have this problem with up and down and I don't find where I made a mistake.
    Basically the enemy can only go up and down or left and write with a bool that doesn't change during play and only the direction change (1 or -1).
    The animation is working with my blend tree on the animator windows. The only thing weird that I noticed was that on the inspector of my blend tree, when I put the red dot between the middle and the 'movingLeft' animation it displays the 'movingRight' animation but on the other side of the 'movingLeft' dot it displays the good animation.

    Sorry if my explanation wasn't clear : I uploaded the entire project for you to see the problem
    https://drive.google.com/open?id=1mEgdhcmtedWXvdXgmEbBIbRumjJ0vHC4
    (I don't know witch part to upload so I put the entire project)
    Also sorry if my english isn't that good Iam french
     
  2. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    47
    Didn't get your explanation. Will download the file and test it tommorow as it is night here. I will check the problem (If I find any). Will give you the fixed file as soon as possible.
     
  3. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    47
    Just checked the project. Seems like the RightAnimation doesn't has it's own sprites and is using the same sprites as LeftAnimation. Thats why it seems like one of the animation never occurs, but actually both are occuring, there is no problem in script. I suggest fliping the animation for left animation manually in some 3rd party tool like photoshop. Then apply the flipped sprites in the animation.
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    404
    There's no need to edit the sprites, you can just use the Animation window to edit the animation so that it sets the Flip X toggle on the SpriteRenderer.
     
  5. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    47
    I'm not that great at 2d games, but I have already tried your solution and fliping it will cause both animations to flip as they both are part of same enemy.
     
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    404
    No, you can animate a bool just the same as an object's position or rotation. So you can set the flip flag as part of the animation. One direction sets it to true and the other to false.
     
  7. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    47
    Didn't knew about that... Thanks..