Make a 2D Space Shooter Game: Asteroid Ambush in Unity (Tutorial)
Tags: tutorial, csharp, unity3d, cloud
Published: 2022-07-26 00:43:17

For quick art changes that need to be swapped out quickly across platforms for updates, [echo3D](http://www.echo3d.co\) makes it easy to do this by simply using an API key. Assets are stored on the [echo3D](http://www.echo3d.co\) cloud and called at runtime.

In this tutorial, you will import asteroids and planets as the obstacles in Asteroid Ambush!

![](https://miro.medium.com/max/1152/1*nVO-ljhkNXJBgGkbnfLLAA.gif)

***

<center> Click this link [**https://go.echo3d.co/c3nA**](https://go.echo3d.co/c3nA) or scan this QR code to see something out of this world 🪐.

![](https://miro.medium.com/max/1374/1*TGVQWZhpPxBTMyeA5RvNMw.png)</center>

***

Register
============

Don’t have an echo3D account? Register for FREE at [echo3D](https://console.echo3d.co/#/auth/register).

Version
=======

[Unity 2020.3.25f1](https://unity3d.com/get-unity/download/archive)

Setup
=====

*   Clone this [repo](https://github.com/echo3Dco/Unity-echo3D-Demo-AsteroidAmbush/), see the full README
*   [Import the Unity SDK](https://docs.echo3D.co/unity/installation)
*   [Add the assets](https://docs.echo3D.co/quickstart/add-a-3d-model) to the echo3D console from the Unity ‘Models’ folder
*   Uncheck the [Security](https://docs.echo3d.co/web-console/deliver-pages/security-page) box in your console
*   In Unity, open the _Game_ scene
*   Drag the _echo3D_ script onto the Planet 1–3 and Asteroid 1–3 objects in the Hierarchy
*   Add the API key and entry ID for each object in the Inspector

![](https://miro.medium.com/max/1400/1*0Z_JDVXFCJNPaE9CkL18BA.png)![](https://miro.medium.com/max/1040/1*-T_RzpcgJp9aAFEyxPYf-Q.png)

*   In the Hierarchy, make sure to the boxes are unchecked for the Sprite Renderer for Planet 1–3 and Asteroid 1–3
*   Press _Play_ in Unity to see where the 3 assets show up in the scene so you can modify the [metadata](https://docs.echo3d.co/unity/transforming-content) in the console
*   Adjust the [metadata](https://docs.echo3d.co/unity/transforming-content) in the echo3D console as follows so the assets appear within the colliders. These may work for you:
    Asteroid 1: scale: .02, yAngle: 180, xAngle: 90, x: -1.7, y: 3.6
    Asteroid 2: scale: .02, yAngle: 180, xAngle: 90, x: 2, y: 2
    Asteroid 3: scale: .02, yAngle: 180, xAngle: 90, x: .9, y: -1.2
    Planet 1: scale: .02, yAngle: 180, xAngle: 90, y:3
    Planet 2: scale: .02, yAngle: 180, xAngle: 90, y: -3.5, x: 1.5
    Planet 3: scale: .02, yAngle: 180, xAngle: 90, y: -3.5, x: -1.5

Run
===

*   Press _Play_ in Unity and click in the Game window to change the rocket’s direction. Hit the 3 asteroids to save the galaxy! If you hit the planets, the game will restart. Control rocket with your 
mouse click.

Switch Out Assets
=================

*   Find new asset in the echo3D console (Or you can upload your own or choose from our library)

![](https://miro.medium.com/max/1200/1*Ej527j0FyKH-Niin_tC4Ig.gif)

*   Get the API key and entries ID

![](https://miro.medium.com/max/1400/1*0Z_JDVXFCJNPaE9CkL18BA.png)

*   Swap them out on the echo3D script in the Unity Hierarchy and see your assets change when you run in Play mode

![](https://miro.medium.com/max/664/1*LIJnwnUcRyRt4Eskmb6QyQ.png)

Learn More
==========

Refer to our [documentation](https://docs.echo3D.co/unity/) to learn more about how to use Unity and echo3D.

Support
=======

Feel free to reach out at [support@echo3D.co](mailto:support@echo3D.co)or join our [support channel on Slack](https://go.echo3D.co/join).

Sources
=======

*   Space assets: [jcomp / freepik](https://www.freepik.com/free-vector/spacecraft-shuttle-exploration-fly-outer-space-vehicle-machine-astronomy-station-vector-illustration_25273368.htm#query=rocket%20ship%20and%20planets&position=1&from_view=search)

Support
=======

Feel free to reach out at [support@echo3D.co](mailto:support@echo3D.co) or join our [support channel on Slack](https://go.echo3d.co/join). For additional troubleshooting, debug [here](https://docs.echo3d.co/unity/troubleshooting).

Screenshots
===========

![](https://miro.medium.com/max/1154/1*SBNX81t2izjMiDcNWiSCOQ.png)![](https://miro.medium.com/max/1140/1*9egfp2zoAR84l-4V1yJDKQ.png)![](https://miro.medium.com/max/1136/1*QBCJ7ovVMiM4tMDRcDqwjg.png)   

More Tutorials
==============

For more easy tutorials, check these out:

*   [Build a 3D Balloon Pop game in Unity](https://medium.com/echo3d/build-a-balloon-pop-game-unity-free-eed9fe7d8be9)
*   [Get a Quarantine Dog in AR](https://medium.com/echo3d/get-a-quarantine-dog-in-ar-8383ea55376b)
*   [How to Create 3D Content and See It In AR](https://medium.com/echo3d/how-to-create-3d-content-and-see-it-in-ar-free-no-coding-required-369e5b4a4b3e)

***

>_**echo3D** ([www.echo3D.co](http://www.echo3d.co/); Techstars 19’) is a cloud platform for 3D/AR/VR that provides tools and network infrastructure to help developers & companies quickly build and deploy 3D apps, games, and content._

![](https://miro.medium.com/max/1400/1*cNrRDT0JEpkcy-zG6KBNgw.png)