Game Development Reference
In-Depth Information
Exercises
1. Change the hit animation in
Target
script (Listing 15 in page 63) so that the
target the bullet hits moves fast to the front instead of rotation.
2. Change
TargetFollower
script (Listing 20 in page 69) so that it locks the rocket
on the farthest target from the shuttle instead of the nearest.
3. Add a new feature to
ShuttleControl
script (Listing 21 in page 70) to allow the
player to rotate the shuttle using horizontal mouse movement. You must read the
displacement of the mouse pointer and rotate the shuttle around the y axis.
4. Attach the script
BulletShooter
(Listing 22 in page 71) to the target prefab to
make the targets able to shoot bullets on the shuttle. You have to add a new script
that checks for collision between the bullet and the shuttle. Therefore you are going
to need a new bullet prefab. Finally, you have to make sure that all targets look
backwards (i.e. positive direction of their z axes point towards the shuttle).
5. Add a third type of collectables to our ball example in section 3.2, which has
a limited time effect on the collector. This effect is doubling the value of the col-
lected coins during the effect period, so if the collector collects this
Doubler
, and
then collects a coin with value 1, then the variable
money
in
InventoryBox
must be
increased by 2. You can select the ball object from the hierarchy during play, in or-
der to be able to observe the value of
money
all the time.
6. Make a switchable trigger that cycles the color of a light between three values:
red, yellow, and green. You can refer to triggers in
scene12
in the accompanying
project to understand the idea.