I am building a 3D application which requires me to have concentric regular Octagonal Cylinder objects.
My approach:
- Create a Octagonal Cylinder mesh programmatically
- Use that procedure to create multiple of them
Questions:
- Is this approach the best way? (There is no specific need for me to build them at run time. Everything is predefined ; I could keep them ready . I am not sure how to do this)
- I have come across the concept of Prefabs to create instances of GameObjects. (Note: I need multiple octagonal cylinders - concentric) But I don’t know how to use that concept here. Need some guidance here.
Your approach is probably good.
You could create one Octagonal Cylinder in blender. Import it, save it as a prefab, and then assign it to a public variable in your script.
Then you can Instantiate them, multiplying the transform.localscale of each subsequent mesh instance by a diminishing factor.
Could you just model the mesh in a modeling program such as Blender? Shouldn’t be too hard. Then you can scale it to various sizes in the Unity editor and place them wherever they need to go in the scene. If you already have code to programmatically generate the mesh you could try saving this to a file in your Unity folder from within your games code only one time, then delete the code and use the mesh from within the editor (again, scaling/placing it as appropriate).