Nerd For Tech
Published in

Nerd For Tech

Slot Rotation Solution:1

Objective: Spin a Slot wheel

First of all create a group of items and place it under an empty gameobject.

Then add Vertical layout group to the empty gameobject and add a behaviour script which will then rotate the items.

Now create a Vector3 variable which will store the default position(position at the start) of the item group. Then create a speed variable which will define the rotation speed of the items. Then create a float variable that will store the current time and the target time which will then stop the spin.

Now inside the start, define the default position to the local position of the layout group.

Now define a method which will be used by either button or events to start the spin. Here, we define the speed of spin and also define the amount of seconds to spin before stopping then call an Ienumerator function which will handles the spin loop.

And finally inside a Ienumerator function, we loop using While loop which checks for time and will stop after the time reaches the target amount of seconds. After reaching certain amount of seconds, we slow down the speed of spin. Then we move the layout group downwards until it reaches a certain position where the layout group jumps back to its default position and move downwards continuously.

And this is the final result.




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Reduce your docker image size with .dockerignore

How to Serve Responsive Images for Mobile, Tablet, and Desktop

Making Enemy Shoot when behind Player

The Principles of Agile Software (Part 1)

Debugging Wednesday — Cancel this task!

CS371p Fall 2020: Stephen Zheng

Gaara Vulnhub Write-Up

Get Started With Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Slot Rotation Solution:2

How to render Particle System OVER UI Canvas

Modular Design

Space Shooter 2D — Part 5