Unity

Unity Playground - Space Shooter

Making a space shooter

Follow along with the video below to create your very first Unity game. There is no coding so this is a great introduction to Unity. The space shooter playground kit contains everything you need, including a space ship and some asteroids. This tutorial uses Unity 2019.4.8f1 which can be installed using Unity Hub.

Next Steps

  • Using the Patrol script found in the Movement folder you can enemies to move about.

  • Load a new scene to create a new level and switch when all the coins have been collected.

  • Add some powerups, like extra life or speed up.

Bolt

Unity+and+Bolt+-+Product+Thumbnail.jpg

Unity Bolt is a great next step after making a game or two inside Unity Playground. Bolt offers an increase in complexity and control while still having no code. You can view our course for Unity Bolt here.

Share your Unity game on the web!

Have you ever wanted to showcase your game on a website? Here is a quick walkthrough on how to upload your Unity project through Unity Connect.

In this example, we'll use the FPS Microgame. But you can follow these steps for any of the Microgames available through Unity Hub. Before you can share your game on the web, you’ll need to have the “WebGL Build Support” module installed in your editor.

To verify if you have the module installed, launch the Unity Hub, then select the Installs tab.

You will see all the editor versions you have installed.

Look at the latest version you have installed, in this example we use 2018.4 LTS, and verify that there is an “HTML 5” icon in the tile.

WebGL.png



If that icon is present, then you have the “WebGL Build Support” module installed, and you can skip this section.

If that icon is absent, then you will need to update your editor.

Add the WebGL Build Support module to your Unity Editor version


To add the module to your editor, click the “Menu” icon in the top right corner of the tile:

And select “Add Modules” from the dropdown menu.

002.png

Then select “WebGL Build Support” in the following pop up menu.

Then hit "Done".

Share Your Game to the Web

Above is an example of what your personalized game's web page will look like that you can share with anyone. As you can see, you will need an image of your personalized game. Let’s get that first. We recommend just going into Play mode and taking a screenshot from somewhere within your game! You'll need that image toward the end of these steps.

Next, add the WebGL Publisher package in the Unity Editor:

1. From the file menu, select Window > Package Manager.

001.png

2. In the Package Manager window, find the WebGL Publisher package (scroll the list on the left, or search with the search bar). This package was formerly called “Share WebGL Game” (as seen in the screenshot). Make sure to install version 1.2 of the package.

If you’re still running on Unity 2018.4, you’ll still see Share WebGL Game in your Package Manager window. In that case, make sure you’ve installed version 1.0.x to continue with this mod. That’s the version compatible with your current editor version.

Note: Your Microgame might already come with the WebGL Publisher package. If your package says “Update” instead of “Install” you can skip below to #4.

001.png

3. Click Install. This will take a few minutes.

Next, create a build of your project that you can share to the Web.

4. From the file menu, click File > Build Settings.


5. This opens the Build Settings window. Click Add Open Scenes to make a build of the scene you have open.

6. Select WebGL from the list on the left.

7. After selecting WebGL, depending on your settings, you might have to do one or two additional steps, but if you see a “Build” button in the lower right of the Build Settings Window, go to step 8 now. Otherwise:

  • If you don’t see “Build” but you see “Switch Platform”, click it, then continue.

If in the middle of the window you see “No WebGL module loaded” then you need to install this module from the Unity Hub. Unfortunately clicking the “Open Download Page” button does not currently work.

  1. Save and close your game/project (close Unity).

  2. Open the Unity Hub app and click Installs from the left sidebar.

  3. Under 2018.4.x LTS click the settings icon.

  • Click Add Modules

  • Select WebGL Build Support from the list of Platforms > Done

  • The module will install, and after successful installation, you’ll see this icon appear:

  • Click Projects and open your Microgame Project.

  • Now you can start at #4 above. Note for #4: Since you will have already clicked “Add Open Scenes” you’ll just need to √ check the box next to the scene name in the “Scenes In Build” section of the Build Settings window.

8. Click Build. This will take a few minutes.

9. Save the build to a local folder on your computer. Note: Do not save it in the same folder as your Project, pick a new destination.

Finally, share the build you just created to the Web.

10. From the file menu, click Window > Share WebGL Game

001.png


11. Add a fun name and image for your game. Remember, the name and image will show up publicly and it will be the first thing people see on your game's page!

001.png

13. A link is automatically generated that you can now share with friends and family so they can play your game! You and anyone you share the link with can view your game by clicking on the link.

14. Complete more mods, then repeat from step 4 to automatically update your game’s webpage to the latest build.

Note: Make sure to copy and save the link to your game in a location where it will be easy for you to access it again. But you can always find the link on your Unity Connect profile page, see the next step for details.

Access the link to your game via Connect

You can always find the link to sharing your game on your Unity Connect profile page (requires login).

  • Login to Unity Connect.

  • Click on your user icon then user name, which takes you to your profile home page.

  • Click on the “Games” tab in the navigation menu.

  • Click on the title or image of your game, which will take you to a page that displays the shareable link.



Publishing a Unity Game

We have published a game and have put it on our website, Maths Monkey. This free game is made using Unity tests odd, even and prime number recognition as the player throws bananas at plants depending on the number that is shown.

Unity comes with multiple different platforms a build can be delivered on. Since we want a web game, we will build an HTML 5 Unity WebGL version. This is a module that needs to be installed, but you can do that within Unity.

MathMonkeySimmerEmbed.png

The Steps

Open the Build Settings menu with Ctrl + Shift + B or Navigate there using File > Build Settings.

build.png

Once the menu is open, select WebGL. If you need to install it click on “Open Download Page”

webdl.png

When WebGL finishes installing, click Build. You will then need to select a folder for the build to be created in. Create a folder called “Build” so you can quickly find it.

buildfolder.png

The build will take a while to complete, depending on the power of your CPU. Unity is CPU intensive while building games.

When the build is complete you will have a inside your build folder an index.html and some other files.

indexbuild.png

The final step to publishing your build is uploading it to a website, Simmer IO is a great website for sharing Unity WebGL games. Go to: https://simmer.io/upload to upload your game.

If you want to learn how to make your own Unity game to share and publish you can view our course here.

We also have a list of some great Educational Unity Games that you can play in your browser

Games made in Unity: Hollow Knight by Team Cherry

Image source from Hollow Knight by Team Cherry (2017)

Image source from Hollow Knight by Team Cherry (2017)

It was the shared nostalgia for a “classic game” that pushed three Australian game developers to make their own studio, Team Cherry, in 2012. Ari Gibson, William Pellen, and David Kazi from Adelaide bonded over Zelda II: The Adventure of Link, while brainstorming what would’ve become a hot-selling title and one of the best representatives of the glorious metroidvania game genre. Nonetheless, like many successful studios, this one came from simple, humble beginnings as well.

Combining a game-jamming mentality with massive animation talent, Team Cherry broke into the large leagues in 2014–15 aided by their very successful Kickstarter campaign and diverse stretch goals. More than delivering on their early promise, Hollow Knight was released in February 2017 and is keeping half-a-million side-scrolling, bug-zapping gamers very enthusiastic.

Image source from Hollow Knight by Team Cherry (2017)

Image source from Hollow Knight by Team Cherry (2017)

Wicked, wonderful, and just plain weird, Hollow Knight can be a challenging and artful insect-based adventure. As a cute little bug, you go up against deadly creatures and complicated traps while unraveling the mysteries in fungal wastes, bone temples, and ruined “gothic-like” underground cities. Buying maps along the way, you wield the Knight’s nail, a sword-like weapon, to keep wondrous enemies and fearful bosses at bay.

The game emphasizes skill and exploration across the vast, interconnected underground kingdom known as Hallownest. The key element the developers were interested in reproducing was the sense of going on a grand adventure in a strange land full of monsters and funny characters and secret nooks and crannies, in order to convey the feeling of forging your own path in uncharted territory and having to face unknown dangers.

Brought to life by stunning visuals, Hollow Knight has been well received by critics, holding an aggregate score of 86/100 on Metacritic, and described by one PC Gamer critic as “the most beautiful hand drawn game [he’d] ever played.” Another reviewer lauded the gameplay too: “Hollow Knight knocks it out of the park in terms of gameplay and presentation with a number of the most effective 2D animation I've seen for a game.”


Hollow Knight is a superb reminder that lovely games don’t necessarily must target grand technical achievements. Team Cherry decided to require full advantage of built-in development tools in Unity and extensions available on the Asset Store so as to satisfy their technical goals. This allowed them to concentrate on what they're best at: creating stunning art. They produced the striking visual style from hand-drawn art and traditional animation created in Photoshop and saved as simple PNGs. Then they assigned a couple of easy shader types including sprite_default and sprite_diffuse with minor modifications to those assets. Rather than using complex 3D lighting systems, they handled lighting with soft transparent shapes. The team built levels with 2D assets layered in an exceedingly 3D environment using many of Unity’s out-of-the-box 2D features, including 2D Physics, Sprite Packer, and therefore the Particle System with the assistance of the 2D Toolkit from the Asset Store.

While the team does have some coding experience and did write custom scripts, they created all the enemies and interactive elements using Playmaker, a five-star visual-scripting package.

How to start making Pokemon GO

Pokemon GO is a popular android / iOS game that uses augmented reality to provide fun interactions. Niantic, the company behind Pokemon GO, started as an initial startup within google before branching out as its own private company. The company primarily focuses on location-based games and has also made other games such as Ingress Prime.

PokemonGOImage.jpg

Pokemon GO utilities a pre-existing database from Ingress to place poke-stops and gyms in the world. Pokemon GO also uses the Open Street Maps API and also location services to place the player in the world and then uses the database to show the surrounding Pokemon, Pokestops and gyms.

With all this, we can break down Pokemon GO into smaller components, which is the initial starting point for how any game is made. Prototyping is essential and this consists of paper and digital versions. Unity is an excellent platform to so in; anyone can learn to code and build a game within Unity. So, the base components are: The map screen with all the Pokemon, catching a Pokemon and also storing the Pokemon. These components also help form the core gameplay loop.

Pokemon.png

Let’s look at how we can code a small piece of the game, catching a Pokemon. We can create a Pokemon class. A class acts as a blueprint that can store all the information we need about a Pokemon.

Next, we can add detection for if the Pokemon is hit with a poke-ball. There is always a chance that a Pokemon will flee, which is where the difficulty comes in. We can set the difficulty to be between 1-100 and act as a percentage that a poke-ball will hit.

Collision.png

The OnCollisionEnter function is the collision detection system within Unity. Objects with a collider on them that touch will then trigger the function. The next step is needing to check if the object is thrown is a Pokeball. This helps future proof our code when other items are added like berries. Finally, we check if the Pokemon is caught by comparing a random number to the difficulty.

Overall once breaking down a game enough into smaller manageable chunks you can quickly learn the secrets behind how a game was programmed.