Search Unity

Resizing an object with EdgeColliders2D using animation

Discussion in '2D' started by jbassking, Jul 3, 2015.

  1. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    Hi everyone.

    I have a pipe with a 90 degree elbow on the right side. Using animation I want to resize the pipe so the elbow moves to the left and back to the right while keeping the left side of the tube in the same place at all times.
    I think I figured out how to do this with the pipe itself but I don't have any idea how I would get the colliders to move with the different parts.
    Any suggestions?
    Thanks!
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    If I'm understanding correct, I think this would be the easiest way to do what you want...

    Split the objects into two parts. One part will be the object that doesn't get resized and the other will be the part that is to be resized.

    Make sure that the pivot point on the resizeable object is at the stationary point. That is the point where it intersects with the object that won't be resized (I'm guessing the left edge in this case).

    When you resize the object it will grow away from the pivot point, that is it will grow towards the right if the pivot point is on the left extreme. If the growing part has got a collider, the collider should resize correctly.
     
    theANMATOR2b likes this.
  3. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    That sounds like what I want. How do I change the pivot point?
     
  4. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Chose the sprite, click on the "Sprite Editor" button in the inspector. The blue dot on the sprite is the pivot point, drag it where ever you want it and press "Apply"
     
  5. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    Thanks!