Hey guys, I am struggling with the system of dynamic creation fortune wheel elements like on the screenshot below. or the reference - Hit Reward - Hit & Win (beavystore.com)
I need to create such a sections, with the raycast ability and … that’s it…
Any ideas of how it could be done? I would really appreciate your help
I would do it as follows:
- make a wedge prefab:
→ centered at the point
→ has a backing “thing”
→ has a number text
→ has a graphic “thing”
→ has a script at its root with dragged-in links to each of the above items.
Now in your main controller for the wheel, spawn X number of these things, rotate them, and set their relevant bits: color, shape, number, etc.
For “thing” above, substitute either Sprite / SpriteRenderer, or perhaps UnityEngine.UI objects, or if you prefer, do it with your own 3D geometry. Either way the script remains fundamentally the same.
Attached is an example of this process, done for an arbitrary number of things using UI.
Work slowly and iteratively:
Imphenzia: How Did I Learn To Make Games:
What does dynamically mean to you? Do you just want to replace / exchange the icons and text / score of each premade section, or are you talking about actually creating variing number of sections (just 3 or 20 or …)? The example you’ve shown may use a cyliner / circle collider. Wheel of fortune doesn’t require to raycast individual sections as the section choosen can be reduced to the angle where you hit / stop.
Creating different number of sections (and maybe different sizes of individual section) would be a lot more complex than using a premade wheel and just exchanging the content of each section.