"Shoot The Thing" (laser defender); quite vanilla, but has a few extra bits n bobs

Hi fellow Unity neophytes,

Game link: http://gamebucket.io/game/e09aeadd-caf2-4351-b919-e9297b107697

Deviations from the course:

  • More particles. Ship explosions, ship thrusters (player ship has left/right thrusters also), enemy lasers have a simple glow particle on them to help them stand out better.

  • Created a “ButtonKeyboardListener” script for the menus so there is no need to manually click on “Play again” with the mouse. (A pet peeve of mine in web games). Code at bottom of post.

  • Modified the enemy laser spawning behaviour to prevent two enemy shots in a short space of time. Has a minimum time that must pass before firing, and increases the odds of it firing as it tends toward a max time.

  • Player health reduced to 1. Lacking any hit feedback, and with the simplicity of the game, I decided it’s marginally more interesting if the player dies as soon as they are hit.

  • Used the Invoke(string, float) method to let the player’s ship finish exploding before moving to the game over screen.

  • Added hit animations to the ships, that plays either during arrival flight or in idle state. This was done by adding a 2nd layer to the animation graph, set to ‘additive’ so the hit animations contribute to any existing animation.

  • Music, sound FX are all custom made (music is very repetitive, sorry!)

ButtonKeyboardListener implementation;

public class ButtonKeyboardListener : MonoBehaviour {
	public UnityEngine.UI.Button button; // drag Button (script) component into the inspector field)
	public KeyCode key; // select 'Space' from the drop-down list (an array of possibly button would be better but that suffices)
// I used OnFixedUpdate instead of Update as I thought this might result in better input responsiveness.
	void OnFixedUpdate() {
	    	if (Input.GetKeyDown(key))
		{
			button.onClick.Invoke();
		}
	}
}

Love the animation for enemy jet propulsion as well as the explosion. It looks really cool and that’s something I’d like to do at some point, but since I haven’t learned sprite animation yet in the course, I decided to go with purely particle systems.

Kudos on the key press at the menu scene. Definitely my pet peeve as well. I like your implementation better than mine since I used public string key rather than Keycode key. Your way is much more intuitive and less likely to have error. Took me a while to figure out that “space” was the correct key string rather than “Space”.