- Home /
Add PolygonCollider2D from code and ignore sprite mesh
I'm adding PolygonCollider2D at runtime with code on the objects that have SpriteRenderer.
And doing that automatically makes this polygon the same shape as the sprite. That leads to profiler spikes with "MeshGenerator.TraceShape" and "SimplifyShape".
I don't need that, because I'm changing the polygon shape manually right after it was added. Also, I don't want to add a collider to any other object.
So, my question is - can I .AddComponent() which will ignore the attached SpriteRenderer and will create a default (pentagon) polygon shape?
Answer by Totoro205 · Apr 08, 2018 at 11:08 PM
Hello, I was wondering whether you found a solution to your problem, I kind of have the same issue.
Your answer
Follow this Question
Related Questions
Change polygon collider depending on the animation 0 Answers
How to disable many colliders in the same game object 4 Answers
Is PolygonCollider2D a legit way to check for mouse clicks in irregular shaped sprites? 1 Answer
Rotating Box Collider 2D independent of its gameObject [v4.7.2f1] 1 Answer
When my project is built my polygon collider does not change. 1 Answer