Game Development Reference
In-Depth Information
Listing 28: A script to rotate objects around the global y axis
It is possible to specify randomStartAngle to avoid having a lot of object that rotate similarly
and hence have a nice randomness in the scene. Notice the use of Random.Range()
function, which can be used along with lower and upper limits to generate random numbers
in between. For example, we use it here to get a random angle at the beginning of the rota-
tion, which lies between 0 and 180 degrees.
All collectables in our scene are going to have Collectable and YRotator script. For instance, you
can say that we are going to use rotation as a sign to tell the player that this object can be col-
lected. Lets begin with the coin, which can be made of a cylinder with a scale of (1, 0.02,
1), and we can put a golden texture on it to give the feeling of a real coin. It is also a good
idea to add a point light as a child to the coin. We are going to give this light a yellow color,
Search WWH ::




Custom Search