Search Unity

Generate 3D Circle Segments

Discussion in 'Scripting' started by ekaralar, Jan 15, 2015.

  1. ekaralar

    ekaralar

    Joined:
    Jan 13, 2015
    Posts:
    14
    Hello,

    I'm trying to wrap my head around how to generate 3d circle segments similar to the attachment - just imagine them as 3d like curved walls.

    arcify-2560x1600.png

    As can be seen, the segments are in different distances from the center.

    Any pointers would be greatly appreciated.

    Thanks a lot.
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    To generate points on a circle, you'd use
    Code (CSharp):
    1. new Vector3( Mathf.Sin(angle) * radius, Mathf.Cos(angle) * radius, 0)
    Where angle ranges from 0 to 2pi. To generate only arcs, use a smaller range (0 to pi gives half a circle)

    You could pass these points to a LineRenderer for example
     
    AlucardJay likes this.
  3. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    just imagine them as 3d like curved walls : Are these solid 3D objects with colliders? Do they move or scale?
     
    Last edited: Jan 16, 2015
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190