Time for action – simple shooting

With the addition of one more object and a single script, we can start shooting at our targets.

  1. First, we need to add an empty GameObject to our tank. Rename it to MuzzlePoint and make it a child of the cannon's pivot point object. Once done, position it at the end of the cannon so the blue arrow points away from the tank, along the same direction as the cannon. This will be the point where our bullets will come from.
  2. We also need something to indicate where we are shooting. The explosions are covered in future chapters, so choose Sphere from the Create Other menu and rename it TargetPoint.
  3. Set the sphere's scale to 0.2 for each axis and give it a red material. This way it can be more easily seen, without being completely ...

Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.