Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Unity Basics!
You have completed Unity Basics!
Preview
Pipes spawning in the same position every time calls for a very boring game. Let’s add some randomization to the gap heights.
Unity 6 Documentation
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Let's open up our pipes spawner script.
0:00
We're instantiating our pipes
0:03
prefab here, and currently we're just
putting 0f as the value for the Y axis,
0:05
so we know this is the value
we want to adjust.
0:10
But we don't want to just hardcode
another number
0:12
in there,
we want something random each time.
0:15
Lucky for us, Unity has a built-in class
0:18
for this, so let's make some space above.
0:20
We just type random with a capital
R and a dot.
0:23
The method we want to use is called range.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up