Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Animations playing off position. (Ruby 2D game).

Discussion in '2D' started by Neosythe, Aug 20, 2019.

  1. Neosythe

    Neosythe

    Joined:
    Jan 13, 2018
    Posts:
    2
    Hi there!

    I've tried my own share of googling but I can't seem to fix the problem (maybe I'm just dumb).

    My issue is with the animation section of the Unity Ruby 2D game tutorial. Animations for the robot enemy specifically.

    All the correct animations play depending on the movement - however, the animations play a little bit up on the Y axis. So the image hops up when the robot starts moving and the box collider 2D doesn't move with it. So when the game is playing there is an invisible damage hit box floating below the enemy. Which is obviously no good.

    How can I get the animations to play in the original position - and/or how can I get the box collider to follow the animation? (Pictures attached).

    Spent 2 hours so far trying to figure this out but apparently it's beyond me.

    Save me Superman! 1.JPG 2.JPG
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
  3. Erriikk

    Erriikk

    Joined:
    Apr 27, 2017
    Posts:
    1
    Struggled with this myself. Saw you posted in 2018, but for anyone else coming across this problem here is how I fixed it:

    Find your robot sprite and select "Bottom" on the Pivot setting.
    Then move your box collider into position again.
    Then move the robots into position again where you had them earlier.
    Then the animation will sit right with you.

    Hope this helps you/someone!
     
    Soukupis, MatrixLyn and mustachesweat like this.
  4. MatrixLyn

    MatrixLyn

    Joined:
    Oct 10, 2020
    Posts:
    2
    Thanks, been searching for the answer for this problem. So many people has replied, some wrote two pages of theories which noobs like me can't understand at all. You have explained and solved the problem in 4 lines. Now another problem pops up, the animation sprite is much smaller than the static standing robot size. I've tried to rescale the animation, but the static standing sprite will scale similarly as well. Now whenever the game run, the sprite will suddenly becomes smaller than the idle standing robot sprite. Any ideas anyone?

    Update:
    Answering my own question. Found this:
    https://answers.unity.com/questions/1281840/my-sprite-size-changes-between-animations-1.html

    So what i did was:
    1. Select the robot sprite, in INSPECTOR, change mesh to Full Rect.
    2. Select the PREFAB of the robot, in INSPECTOR->Sprite Renderer->Draw Mode. Change to Sliced (previously was Simple).

    Now i can resize the sprite and the animation will scale accordingly.

    Hope this helps someone.
     
    Last edited: Oct 21, 2020
    BryanL likes this.
  5. Soukupis

    Soukupis

    Joined:
    Oct 28, 2020
    Posts:
    1
    I LOVE YOU!!!