Galaxy Shooter — Phase II: Core Programming
Day 49 — Aspiring Game Creator
2D Game Dev: Galaxy Shooter
Objective: New Enemy Type — New Long Range Laser Cannon
The Long-Range Cannon makes use of Unity’s Line Renderer.
Adding & configuring the component is simple, at least this implementation is. The line will have two points, start and end (the size is 2). The length is 5 which means setting the start pos at y=1 and end pos at y=6. The width defaults to 1.0 which is simply too thick, so 0.15 feels good.
Once a reference to the Line Renderer is made in the enemy class, “firing” the laser is 5 basic lines within a coroutine. The coroutine is used to provide a split-second pause after the line is drawn to give the illusion of the laser beam.
Enemies do have an accuracy attribute, some more than others.
If the laser cannon is a direct hit the Damage method on the player is called.