- Home /
Question is off-topic or not relevant, not a Unity specific technical question.
Help with drawing circles in real time
I'm creating a 2D space game where I am procedurally generating a simple star system. I would like to be able to render a circle at the orbits of the planet. Something like this: http://spaceengine.ucoz.ru/_fr/11/s0498649.jpg ,but in 2D. The centre of the circle will be at the star and the radius the distance of the planet to the star. In know about line renderer but I have no experience using this. Can someone help me with this?
Answer by AlwaysSunny · Dec 30, 2014 at 10:22 PM
The lines in the linked image look like trails, not circles. At least for prototyping, the trail renderer will produce acceptable trails.
For circles, it gets a little funny: You could obviously scale a raster image of a circle, but this is only useful in certain situations. Not suitable for dynamic sizes or scrutiny at many resolutions.
You could draw N line segments that sweep a circle's circumference. Learning to do this will impart handy knowledge for other line- and shape-drawing techniques. You'll learn mesh generation, billboarding techniques, and make use of the Graphics.DrawMeshNow method to render the mesh to the screen.
The other method I've used involves a rigged mesh of a 2D toroid slice. Basically like a washer or squished doughnut. The root bone controls the outer diameter, a child bone controls the inner diameter. This is a very cheap and flexible method, but it involves some initial coding (and 3D software like Blender) to achieve a good result. Once your single rigged mesh and control script are complete, you can re-use them to draw a circle of any size, thickness, material, or planar orientation.
Follow this Question
Related Questions
How to find the radius area of linerencderer drawn circle and move objects inside ? 1 Answer
Lighting for a planet on mobile 0 Answers
How to subdivide a cube sphere 0 Answers
Visualizing area of influence in a sci fi game 1 Answer
Keep line renderer width same on screen no matter camera distance 1 Answer