Game Development Reference
In-Depth Information
The script is fairly simple: when it collides with another object, it informs the colliding object
about the painful that occurred and passes the amount of damage that has to be taken. We
can use this scripts to make prefabs for two types of projectiles with 5 and 10 damage power.
For this example we can use shining green and red balls as projectiles. We can make them
shining by adding a point line object with the same color of the texture as a child. Illustration
84 shows how these projectiles are going to look like. Since these projectiles need to be
controlled by physics simulator, we need to attach rigid bodies to them. However, it is neces-
sary to disable Use Gravity option for the rigid bodies to prevent them from falling on the
ground and hence keep moving in straight line when launched.
Illustration 84: Small green shining projectile (left) with 5 damage, and big red
shining projectile with 10 damage
These two prefabs need to be added to projectiles array inside shooter prefab. As a result,
all shooter scripts attached to the cannons in the scene are going to have these projectiles
automatically added to their projectiles array. We have now completed the playground in
which our game is going to be played, so the next step will be creating the player. Our
player for this game is going to be a simple cube with PhysicsCharacter attached to it, in
addition to TopViewControl shown in Listing 73, which allows us to control the character
from a top view and move it in the four directions. Additionally, we have to disable jump
by freezing the movement of player's rigid body on y axis. To prevent unwanted rotations, we
have also to freeze rigid body rotation on x, y, and z axes.
Search WWH ::




Custom Search