Game Development Reference
In-Depth Information
36.
37.
//Reshoot after random time
38.
ShootRandomly();
39.
}
40.}
Listing 71: A script to randomize type of projectile and shoot timing
The script performs shooting by adding impulse force to the instantiated projectile, which
must be chosen randomly from projectiles array. After each shooting, ShootRandomly()
is called. This function generates a random value between minTime and maxTime , then
uses this value as latency before invoking Shoot() again. Now we have to create the two
projectiles that will be shot by these cannons. These projectiles must have the ability to de-
crease player's health when they hit him. Therefore we call their script PainfulProjectile ,
which is shown in Listing 72.
Search WWH ::




Custom Search