Time for action – simple shooting
With the addition of one more object and a single script, we can start shooting at our targets.
- First, we need to add an empty
GameObject
to our tank. Rename it toMuzzlePoint
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. - 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
. - 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.