I’m trying to make a roulette wheel with red and black rectangles scaled larger on one axis then another. And i need to set their position around a wheel and make them rotate towards the wheel in the script such as the image below may I please have some help. Also the rectangles are in a list so they can be removed and added during the game.
Steps to success:
- have a center object to spin (blank GameObject)
- spawn each chunk, offset it it outwards appropriately.
- parent it to the interior GameObject
- rotate that center GameObject by the correct amount ( 45 degrees based on your 8-piece drawing above, but more generally it will be 360.0f divided by count)
Put that in an 8-count loop.
Now you have a reference to the center object to spin.
Quaternion.Euler() is how to generate rotations, and Transform.Rotate() is how to rotate an existing transform.
OR… just look at any one of the ten billion youtube tutorials out there for making wheel of fortune or roulette wheels. If you can’t get it from that, nothing more in this little text box will help either.
Two steps to tutorials and / or example code:
- do them perfectly, to the letter (zero typos, including punctuation and capitalization)
- stop and understand each step to understand what is going on.
If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.
Imphenzia: How Did I Learn To Make Games:
Being as you tagged this 2D-physics I presume you want the red/black/yellow to collide in 2D?
If so then it’s as simple as a parent GameObject with a Rigidbody2D with a body-type of Kinematic. Add a CircleCollider2D to it and the visuals (maybe a SpriteRenderer for the yellow circle). Then add child GameObjects for each red/black rectangle, again with a SpriteRenderer and a BoxCollider2D for collisions offset to the positions you want.
You can then set the angular velocity of the parent Rigidbody2D and it’ll spin and collide with stuff. You can continue to modify the angular velocity to slow it down over time i.e. damp the angular velocity.
Because Kinematic bodies don’t react to forces, nothing, not even collisions will slow this down so you have total control.