I’m building a wheel of fortune type game and wondering how to draw sectors and particular draw sectors into circles. I can’t find any good solution for our skill level nor any existing code templates for this. The concept for sectors:
- Sectors that are dynamic (however, for starters even static sectors
would be fine)
- Sectors have to have some kind of filling
- At the end of the sectors there should be “bars” like in original
wheel of fortune
The other stuff is easy enough for me, it’s just these damn sectors… So how to draw sectors in 3d space or draw the sectors into 3d circle in Unity scripts?
Create an empty game object with scripts that will act as your “wheel”. In your modeling software, create a “sector” mesh that represents an individual “space” on the Wheel of Fortune wheel, making sure the origin of this mesh is where the center of the wheel would be.
In Maya, you could do this easily by creating a cylinder at the origin (location 0,0,0) whose “top” or “end” has the same number of subdivisions as the number of “sectors” you want your finished wheel to contain. Then, delete all the faces except one, which becomes your wheel piece or “sector.” Texture this mesh with the art you want a piece/sector to have, and save a different copy for each possible different kind of piece you want to have appear on your wheel. You could use different colors of pieces to start off simple. Put another way, make one mesh file in your Unity assets folder for each different piece that can exist on your wheel.
Now, you can use Instantiate() to create individual sectors at the same position as your “wheel” GameObject, and change the rotation of each piece to array them around your wheel’s origin (something like Quaternion.Euler but there’s lots of ways to do it). As Hydraxia pointed out, if you have 12 sectors you want to rotate each 30° from the previous to construct a whole wheel. Since you’re choosing which pieces to load each time you Instantiate, you can construct a different wheel dynamically as you wish.
Lastly, if you parent each cloned object to your wheel GameObject (by setting the object’s
transform.parent) you can simply rotate the wheel GameObject and all the individual sectors will rotate all together as well.
For the “bars” or spokes along the rim that make the clicking noise in the show, just build them into the “sector” model and make sure they’re spaced evenly when all the sectors are put together.
If you need more specific examples of how to do any of these steps, let me know and I can include them, but you seemed like you needed a conceptual answer since you’re currently trying to draw dynamically onto a circle or something like that. =)