Giter VIP home page Giter VIP logo

06-laser-defender's Introduction

Introduction to Laser Defender

  • Laser Defender introduction
  • What Laser Defender teaches
    • Animation basics
    • Using Trigger colliders
    • Introduction to Particle Systems

Section 6 Game Design Document

Your Laser Defender Assets

Section 6 Notes

Importing The Menu System

  • Open our previous game and import the menu system
  • Create a unity package
  • Import package into Laser Defender
  • Alternatively, we can use the unitypackage from the section bundle at the beginning of this section

A Starship We Can Control

  • Find a suitable sprite asset
  • Import into our game
  • Create a Player Controller Script to move it
  • Restrict the movement to the playspace

Useful Links

Restricting The Player's Position

  • How to stop the spaceship from going outside the playspace
  • We will check the position when moving and restrict it to something sensible

Creating The Enemies

  • Creating the enemy prefab
  • Create an EnemySpawner that will generate enemies at runtime
  • Make the EnemySpawner generate a single enemy on start

Creating Enemy Positions

  • Create a position within the EnemyFormation
  • Use OnDrawGizmos() to show the position
  • Turn the position into a prefab
  • Change the spawning script to keep track of positions

Moving The Enemy Formation

  • Showing the Formation in the Editor
  • Show all four sides of the formation
  • Move the formation side to side

Fixing The Formation Movement

  • Fix the boundary issue with the formation getting stuck on the edge of the playspace

Spawning Projectiles

  • Player object should spawns laser when [space] is pressed
  • Create a laser prefab
  • We use Instantiate() to create a new one
  • We give the projectile velocity

Shooting Enemies

  • Enemies will respond to the projectile hitting them.
  • We use Kinematic Rigidbody Triggers for the enemies
  • On trigger, enemy takes damage according to projectile component
  • Defining the projectile behaviour
  • Detect laser collisions
  • Getting the damage from the lasers

Enemies Shooting Back

  • Enemies will randomly shoot back with a tuneable frequency
  • Make enemies shoot at the player
  • Create enemy projectile
  • Getting hit by the enemy
  • Tuning the frequency

Controlling Collisions with Layers

  • Player shoots itself when firing!
  • Lasers hit each other!
  • We need the player's projectile not to collide with itself or the player
  • We need the enemy projectiles to not collide with enemies or each other

Detecting Enemies Have Been Destroyed

  • We need to know when all enemies are dead
  • We use the childCount property of a transform on the positions - an empty position is a dead enemy
  • We re-spawn the enemies when that happens

Spawning Enemies One By One

  • Learn how to use recursive functions for the first time
  • Make something happen multiple times with a delay between each time

Enemy Position Animation

  • Enemies should animate in, rather than appear
  • Create an Animator and Animation Controller
  • Create states to represent arriving and flying
  • Add the appropriate animation

Creating A Starfield

  • The background looks a little barren
  • Let's add a starfield with parallax effect to give some sense of depth
  • We can use a Particle System to do this.
  • Explore Particle Effects

Keeping Score

  • Requires Some object to keep track of the scores
  • Create the UI for the score
  • We'll create a ScoreKeeper that we attach to the score
  • When an Enemy dies, we'll call the ScoreKeeper

Sound Effects For Fun And Profit

  • Adding sound to your game
  • Will make a huge difference to our game
  • Easy enough to do
  • We'll look at playing sounds independently of an object, so that we can play a death sound for the enemies

Sprite Rendering Order

  • Sprite rendering order changes which sprites are drawn on top
  • Lets missiles from the player be drawn below the ship when instantiated
  • Create appropriate sorting layers
  • Laser defender now with layers

Polishing The Menu System I

  • Replacing the menu style
  • Passing the score to the ends

Polishing The Menu System II

  • Adding our own music to the game
  • Adding a background starfield

Useful Links

LD Unity 5 & Web GL Sharing (Optional)

  • Upgrade to Unity 5.
  • About Web GL builds.
  • Build for Web GL and share.

DOWNLOAD Section 6 Unity Project

Here is our Unity project at this point in the section. Use it to compare code / settings etc if you get stuck.

Once un-zipped you can use File > Open Project in Unity, or browse the folders for any .unity file.

You can get to ALL videos end-state by...

  1. Visiting https://github.com/CompleteUnityDeveloper
  2. Clicking on the section name.
  3. Clicking XX Commits at the top-left (XX will vary)
  4. Against the video you want, click the <> button on right.
  5. On final page, click Download Zip button.

Good luck!

Section 6 Wrap Up

  • Recap and what's next
  • New in your toolkit
  • Trigger Colliders
  • Sprite Animations
  • Particle Systems
  • Physics Layers
  • Sorting Layers

06-laser-defender's People

Contributors

bricef avatar robmeade avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.