Game Development Reference
In-Depth Information
AddForceAtPosition() which is called by BulletForceReceiver is going to have its proper ef-
fect on the rigid body of the block and move it. Our building block is now ready and the
walls are affected by sniper and rifle bullets.
The last thing we need to take care about regarding output are RPG rockets. In this case we
have to create a rocket prefab that is launched when the RPG is fired. When this rocket hits
a wall, it must cause an explosion and consequently destroy the wall. To launch the rocket
we need two parts: the rocket itself as prefab, and the launcher as a script that responds to
FireWeapon() message by instantiating the prefab. Let's begin with RPG script, which is
responsible for instantiating the rocket. This script must be added to the RPG weapon game
object. Listing 87 shows RPG script.
Search WWH ::




Custom Search