armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

• 0

# Regular shapes in a circle

## Question

Hello. I am working on a script so as to create dynamically regular 2d shapes, only setting a circle radius in which shape is drawn. For shapes which use an even number of sides it's easy - I post below an example about how to create a regular hexagon (it's more or less the same principe for square and octogon because h² = AB² - (AB/2)² ). However I have no clue how I could compute these coordinates in the circle for shapes which are buildt with an odd number of sides like a pentagon or a heptagon. I am not really good with trigonometry. Have you an idea? Thank you ++

## Recommended Posts

• 0

The problem with your code it’s hard coded. But you know that. All you have to do is know how to create a procedural circle. A hexagon, decagon, etc is just a procedural circle with a set number of points. You can either look at my code for weapon selection on page 2 of the scripts section for 2d or look at this for 3d: Please login or register to see this link.

triangle is 3 points, square is 4, pentagon is 5, and so on

##### Share on other sites

• 0

Thank you OcularCash for your answer. It helped me to find the solution

I can set each point using a radius this way :

More easy - more efficient. It works perfectly. Thank you ++

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.