Lab 2 & 3 - Introduction to Unity
Watch the lab Video
This task consists of 2 lab sessions - we will start today and continue next week. The deadline is before the beginning of lab 4 (you don't have to submit anything in between).
Implement a shoot them up (shmup) style space game.
Your game should look similar to the following picture:
Last year games (part1 + part2): https://youtu.be/UhLd6izH04E
Steps:
- Download graphics files: https://opengameart.org/content/space-shooter-redux
- Download background shader: https://optimatica.eu/courses/shmup/background_shader.zip
- Create a new Unity 2D project
- Make infinitely scrolling background:
- Add graphics and background.shader to your project.
- Create a new background material using background.shader (Shader->Custom->Background), add a suitable background texture to it, change the textures’ wrap mode to “Repeat”.
- Add a 3D quad to your scene, add background material to it, scale it up, move it further on the z-axis and attach it to your camera.
- Make the camera move continuously upwards
- Add player spaceship:
- Add a spaceship sprite to your scene. Attach a new SpaceShip script to it.
- Make your ship to follow your mouse cursor. Hint: Camera.main.ScreenToWorldPoint(mousePosition);
- Bound the ship inside the visible play area. Hint: https://answers.unity.com/questions/501893/calculating-2d-camera-bounds.html
- Add a 2D collider to your ship
- Extra: make your ship tilting left or right depending on the direction you are moving.
- Make spaceship shoot automatically:
- Create a new bullet prefab with appropriate sprite and collider.
- Make the bullet move forward.
- Destroy the bullet when it leaves the view.
- Make the player ship to spawn bullets every fixed amount of time.
- Add enemy ships:
- Create enemy ship prefab, with sprite, collider, and script.
- Add health parameter to it, destroy it when health reaches 0.
- Do damage to enemy ships when they collide with your bullets.
- Add lives parameter to the player ship, restart the game when it reaches 0.
- When the player collides with an enemy remove one life and destroy the enemy ship.
- Add linear movement vector to the enemy ship which configures its movement speed and direction. Trigger enemy movement when it becomes visible.
- Make enemy ships rotate towards their moving direction
- Add multiple enemy ships to your scene and test it.
- Add UI:
- Create a new UI Canvas with canvas scaler that scales your UI proportionally to the screen size.
- Add a score text with a custom font (you can find one under the Bonus folder).
- Add an energy bar that consists of a foreground and background images. The foreground image should have an image type "filled" property.
- Add a panel with small ship images representing remaining lives.
- Add horizontal layout group to the panel to align images automatically.
- Add a UI script to your canvas that gets references to all the necessary UI elements and provides public methods to change score, energy and remaining lives.
- Assign the UI script to a static variable so you can access it from everywhere.
- Add lives and score:
- When your player loses a life, remove it from UI as well.
- Make your player invincible for a few seconds after losing a life.
- Reduce the opacity of the player ship while it is invincible.
- Every time you destroy an enemy ship, increase your score.
Submission
This time you don't submit anything. We will continue during the next lab and then you will submit it once.
NB! Make sure that you have all these steps done before the beginning of the next lab!