Search Unity

Question Unity2D - attach transform to a vector point in a moving animation?

Discussion in 'Animation' started by starvetor, Oct 26, 2021.

  1. starvetor

    starvetor

    Joined:
    Nov 6, 2018
    Posts:
    42
    The title is awfully worded but I'm having trouble explaining it concisely. Basically I have a 2D animation of a walking player sprite. The player is holding a torch which rotates and follows the mouse, so I've detached the arm from the sprite so that the animation doesn't include the arm.

    The problem now is that the character bobs up and down while walking, so the attachment point of the arm changes as the animation progresses. The only way I can think of is finding the Y position of the connection point at every frame and hard-coding the position of the arm using animation events.

    Is there a better way to do this? Any help would be appreciated!