- Home /
Create colliders placed over polygon's perimeter
Hi there.
I have a 2D polygon like below shape and want to create a series of circle colliders over it's perimeter(like red ones) 
I don't have any idea about how to obtain exterior points of a shape sequentially. maybe some information put me on the way.
Thanks for any help
Answer by MacDx · Sep 10, 2017 at 02:42 PM
The polygon collider 2D component has a points field which is an array of Vector2s that define the shape of the polygon. What you can do is loop through the array so you can get the points needed, process that info in whatever way you want and then add the circle colliders.
Here's the API documentation: https://docs.unity3d.com/ScriptReference/PolygonCollider2D-points.html
Tnx. I got it. but do you have any idea to have circle colliders exactly placed sequentially next to each other . If I name them in the loop which seeks points array, they can't place next to each other visually.
if I seek polygonCollider2D.points array in a "for loop" , point located in index 0 is not next to point with index 1 . so it's not true for indexes 1,2 and so on. The no$$anonymous$$al order is not the same as the position placement. I want to get indexes sequentially, like train wagons that sit together and numbered respectively.
Your answer
Follow this Question
Related Questions
OnCollisionEnter2D is called but the actually collision isn't resolving. 0 Answers
Make an object with greater friction slide less when correcting objects positions 0 Answers
Lag Caused by Overlapping 2D Colliders 1 Answer
2D Physics, cannot pass -10 (y-axis) 1 Answer
2D Bike physics are not working 0 Answers