Game Development Reference
In-Depth Information
Listing 87: RPG script to launch rockets based on general weapon
To represent RPG rocket, we are going to use a sphere that is stretched along its z axis so
it look like ellipsoid. For this example I am going to use the dimensions (0.2, 0.2, 0.75).
We can give this ellipsoid an arbitrary texture, and we have also to create a prefab out of
it. Once we have the rocket prefab ready, we set the value of rocketPrefab in RPG script
to that prefab. This prefab needs, of course, a number of components and scripts in order to
behave as we wish. First of all, we need to add a rigid body component to it. Now we have
to think about what does the rocket do: 1) it is launched with a specific impulse force, then
hits the target. Once it hits the target, 2) it explodes and 3) blows the target as well. If the
target is destructible, it must be 4) destructed as well. Therefore, we need four scripts to
perform these four tasks. So let's begin with the first task: launching and moving the rocket.
This task is performed by RPGRocket script shown in Listing 88.
Search WWH ::




Custom Search