0

I am generating planets of various types and sizes for my levels. This dictates which sprite image will be used i.e. a water planet has a different image compared to that of a gas giant etc. Therefore some require a larger radius for the circle collider 2d. I need this to be dead on so that interaction stops immediately leaving the planets collision detection. I have seen other solutions for box colliders and sphere colliders (renderer.bounds.size matching the texture) but with this I need a float rather than a Vector3. I have seen somewhere a solution where they programmatically detected the transparent space around the planet(visible part of the image) , but I cannot find it. I am using the standard shader with the fade rendering mode. If anyone has a solution to this, or has seen the solution i mentioned, I would be very grateful, thanks!

I can post code if needed but I think this is more of a general enquiry.

JonHerbert
  • 647
  • 1
  • 8
  • 23

1 Answers1

0

You can use the Edge Collider and change the vertexes so that it'll match the sprite, or you can use the Circle Collider but change the radius. Anyways, you have more information about colliders with good explanations at https://unity3d.com/learn/tutorials/modules/beginner/2d/collider2d