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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Update Polygon Collider 2d on skeletal animations

Discussion in 'Physics' started by Kidara, May 15, 2020.

  1. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    Hello there,

    the title is pretty much self-explanatory. I'd like to update my polygon collider 2d every frame to match the skeletal animations 2d that I create.
    Is there a way to do so?

    Thank you
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    No and it'd be pretty expensive to do so; especially so because physics doesn't even run per-frame. A PolygonCollider2D isn't a single primitive shape, it's path(s) that form outline(s) that it then has to decompose into multiple convex polygons.
     
  3. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    Yeah I know it's expensive, but I would use only for a simple game with high precision.
    Anyway, the only thing I can do is to generate some spritesheet animation and map a collider on every animation frame, and update PolygonCollider2D with these colliders when animation is called. Right?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    If you feel that this kind of collision fidelity is worth the expense then sure.
     
    Kidara likes this.