Search Unity

Rigid Bodies staying within Rigid Bodies: QuickHack

Discussion in 'Physics' started by MahaloAloha, Jan 14, 2021.

  1. MahaloAloha

    MahaloAloha

    Joined:
    Jan 9, 2021
    Posts:
    31
    I've repped PressStart before, and this is why.




    I'm putting it here in case anyone else was looking for/googles a solution to similar problems.

    In newbie/learner's terms, he's literally using Unity's innate functionality to recognize the edges of imported sprites/images and using it to automatically trace the borders on any body - no matter how complex the shape. It's basically nine lines of code that can save you hours of hand labor and can easily be lent and instanced onto any contained area.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Could you not add a CompositeCollider2D set to "Outline" geometry mode and turn on "Use Composite" on the PolygonCollider2D?
     
  3. lightbug14

    lightbug14

    Joined:
    Feb 3, 2018
    Posts:
    447
    Using a composite collider does the trick:
    CompositeCol.gif
     
    MelvMay likes this.
  4. MahaloAloha

    MahaloAloha

    Joined:
    Jan 9, 2021
    Posts:
    31
    Many methods; one cat.
     
    MelvMay likes this.