Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sprite collision during Animation

Discussion in '2D' started by ammar26, Dec 10, 2013.

  1. ammar26

    ammar26

    Joined:
    Jun 5, 2011
    Posts:
    29
    I have a sprite of a robot character and I have an animation (of robotic hand movement) made from sprites (with the help of dope sheet view). I want to apply a collider on robotic hand in such way that it moves along with the arm. But I couldn't find anyway to change the collider with respect to each sprite frame? I tried Polygon Collider 2D but it remains same through out the sprite animation. Box Collider 2D don't rotate on each frame, it can only change its size and position.

    Does anyone know how to change the collider (rotate more specifically) on each frame of sprite animation ?
     
  2. vinfang

    vinfang

    Joined:
    Jul 13, 2013
    Posts:
    14
    $Rotation2DObject.png

    So if your game object has a transform attached to it, select it and go to your animation window with the animation selected that you want responsible for rotating it. In that window, choose Add Curve, and find the transform rotation that is attached to the game object in that list. From there, add keys based on what frame you want it to rotate, and in the scene rotate the object to the angle you want it.

    From there just continuously add more keys if you want it to rotate more and more. Hopefully the image gives you an idea of what to do.

    EDIT: Erm the image seems tiny, but if you open that in a new tab in Chrome it'll enlarge it so you can see it more in detail.
     
  3. ammar26

    ammar26

    Joined:
    Jun 5, 2011
    Posts:
    29
    Thanks, it helped a lot