Game Show Kit Documentation

 Game Show Kit Documentation
Creating Your Own Scene
We will create a new scene that works similarly to the ​
Spin To Win ​
example.
1. Create a simple scene and position the camera appropriately to see the spinning
wheel. Make sure the wheel has a rigidbody and collider attached.
2. On the rigidbody, turn off gravity and freeze the positions. Lock any rotation axis
you don’t want the wheel to rotate on. Increase the angular drag to 1.
3. Attach the ​
STWForce.cs​
script to the wheel. Alternatively, you can create a new
script that inherits from ​
ApplyForce.cs​
, that script would then need to be
implemented to work as desired, simply override the​
Dragging() ​
and​
Release()
methods.
4. Test to make sure the wheel spins by enabling the ​
Start On ​
button on the
STWForce ​
component. Your wheel should rotate once when dragged on in the
Game window view.
5. Now add visual indicators for the score points on the wheel. Add colliders that will
be used for detecting points selected either on the visual indicators or on an
invisible object, make sure it is near the edge of the wheel and will intersect with
the pointer we will make. Mark the colliders as ​
Is Trigger ​
as true.
6. Attach the script ​
PointValue.cs ​
to the collider objects that will keep track of the
points and set the ​
Point Val ​
to define how much the points are worth.
7. Create an object that will be used as our selector/pointer. Make sure it is near the
edge to collide with the points on the wheel. If it is not reacting with physics, mark
the pointer as ​
Is Trigger ​
as true.
8. Add the ​
SpinnerCollision.cs​
script to the pointer and attach an audio source
component with an audio clip to be played when the pointer collides with a point.
Enable the ​
Play Sound On Trigger Enter ​
boolean so that a sound is made when
the pointer collides with a point.
9. Running the scene, now when the wheel is spun and the pointer collides with a
point, it should play a sound.
Creating a Simple Game
Following the ‘​
Creating Your Own Scene​
’ section, we will implement a​
Game Manager
and ​
State Manager​
to keep track of points and cycle between ​
Intro​
,​
Gameplay​
, and
Win/Lose​
states.
1 1. Create a new game object and name it ​
MySceneManager​
, add an ​
Audio
Source ​
to the object.
2. Create a new script called ​
MySceneManager.cs​
and attach it to the
MySceneManager ​
game object.
3. We will copy the code from ​
SceneSpinToWin.cs​
as a basis for our game
scene. Paste the code into the ​
MySceneManager.cs​
file and rename the
class to ​
MySceneManager​
.
4. Change certain lines of code in your ​
MySceneManager.cs​
file to the
following:
gameObject.name =​
"MyScene";
maxSpins =​
2​
;
if(score >= ​
500​
)
5. On your ​
MySceneManager ​
game object, in the inspector, add a ​
Win ​
and
Lose ​
sound to the ​
Sounds ​
field. Make the ​
Camera Pos ​
have a size of 2
(these can be left empty). Set the ​
Min Vel ​
value to 0.01. Set ​
Time Scale ​
to
1.25.
6. Now, save the ​
MySceneManager ​
game object as a prefab by dragging it into
the ‘​
Prefabs/Actors​
’ folder in the ​
Project ​
window. After saving the prefab,
delete the ​
MySceneManager​
game object from the scene, we will use the
prefab instead later.
7. In the ‘​
Prefabs/Actors​
’ folder, add the ​
Canvas ​
prefab to the scene. Make any
changes to the text/images as needed.
8. In the ‘​
Prefabs/Actors​
’ folder, add the ​
GameManager ​
prefab to the scene.
9. In the inspector​
window of the ​
​
GameManager ​
in the scene, modify the
Scene ​
field to point to the ​
MySceneManager ​
prefab we created earlier.
Increase the size of the ​
Scene Names ​
field and add the name of the scene
you are currently working in at the end of the list.
For ​
Wheel STW ​
add the wheel object from the scene that we will be spinning.
For ​
Pointer STW ​
add the pointer object from the scene that will count the
points. For ​
Win Lose Obj ​
select the ​
WinLoseObj ​
found under the ​
Canvas ​
in
the scene. For ​
Score Obj ​
add the ​
Current Score Text​
found under the
Canvas​
.
For ​
Spin Counter ​
add the ​
Spins Text ​
found under the ​
Canvas​
.
10.Now, create a new script called ​
GameMySceneState.cs
11.Copy the code from the ​
GameSpinToWinState.cs ​
and paste it in our new
script. Change the class name and constructor to ​
GameMySceneState.
2 12.Change these lines of code:
private ​
MySceneManager ​
scene;
scene = (​
MySceneManager​
)GameObject.Instantiate(owner.scene);
13.In the ​
Globals.cs ​
script modify the ​
GameModes ​
enum and add ​
MYSCENE​
.
14.In the ​
GameManager.cs ​
script under the ​
SceneLoaded() ​
method, add the
following code at the end of the conditional:
else if (loadedScene == sceneNames[​
3​
]){
ChangeState(new ​
GameMySceneState​
());
gameMode = GAMEMODES.​
MYSCENE​
;
}
15.Now the game should be playable, and automatically cycle between ​
Game
and ​
Scene ​
states. In the project there should be a ​
GameManager, Canvas,
Pointer, ​
and a​
Spinning Table ​
with ​
Points. ​
When the game is started, it
should instantiate the ​
MySceneManager ​
prefab we created which will
handle the states of intro, gameplay, win/lose, and restarting.
Reference Values
STWForce.cs
1. Force Amount​
: Amount of force to apply when wheel is spun.
2. Arrow​
: Optional arrow indicator to let users know they can spin the wheel.
3. Start On​
: When true, the attached object will be able to be rotated with the
mouse when the scene starts, otherwise it will need to be turned on using a script.
PointValue.cs
● Point Value​
: Value of how much the points are worth. Use negative numbers for
special effects that can be accessed in your scripts.
SpinnerCollision.cs
● Play Sound On Trigger Enter​
: Play a sound when colliding with a point.
● Show Debug​
: When enabled, displays in debug log what point value was collided
with.
3