Time for action – rotating Player in SetupState
There will be a setting in the Inspector panel to set the rotating speed. Why is Player rotating in SetupState
? It allows you to view the changes made to Player. It's also a nice visual effect, much better than just looking at a static screen.
Create a script containing the code shown in the following screenshot:
Create a C# Script and name it
PlayerControl
.Open it in MonoDevelop.
Add the
setupSpinSpeed
variable as shown on line 6 of the preceding screenshot.Modify
Update()
as shown on line 13 of the preceding screenshot.Save the file.
Attach this script to the Player GameObject.
To control the rotation of Player, we need to add the code (shown in the following screenshot) to SetupState
.

The SetupState
class needs to have two pieces of information to be able to control Player.
It needs to know about the Player GameObject
It needs to know about the
PlayerControl
Component script attached to Player
Therefore we need two variables to store this information...