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

Generate positions within a sprite outline or phsyics shape

Discussion in '2D' started by OtakuD, Aug 15, 2018.

  1. OtakuD

    OtakuD

    Joined:
    Apr 24, 2014
    Posts:
    49
    I have a sprite in unity which has it's custom outline and physics shape setup in the sprite editor, I would now like to access this info at runtime and generate objects around the surface of the sprite. The only information I can find so far pertains to attaching a PolygonCollider2D to it and then using the bounds to check if the position is within it's limits.

    Preferably I would like to know the width of the collider at specific heights and divide that up by how many positions I need at that height, is there any way to access the PolygonCollider2Ds dimensions this way or even the sprite shape directly without the need for a collider?

    Thanks!