Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / game / Unity

Day 89 of 100 Days of VR: Endless Flyer – Creating A Multiplier Power-Up with Magica Voxel

0.00/5 (No votes)
6 Feb 2019CPOL5 min read 2K  
A score multiplier power-up!
In this post, we're going to use Magica Voxel to create a power-up model and import it into Unity.

Today, we’re going to finally move on to the second up of our three power-ups! In the past 4 posts, we talked about implementing a magnet power-up, today we’re going to work on a score multiplier power-up!

Just like the magnet power-up, this will be a multi-post series, today we’re going to first focus on getting the assets and importing it in Unity.

I know what you’re thinking: “Come on Josh, we’re just going to grab an asset from the Unity asset store?”

Well, hold your horses! Because this asset is a bit more complicated!

Today, we’re going to:

  1. Use Magica Voxel to create a power-up model
  2. Import it into Unity

What is Magica Voxel, you might ask? You’ll find out today!

Note: Like always, scroll down to the end to get the link to our final product.

Step 1: Creating a Score Multiplier Power-Up

Step 1.1: Download Magica Voxel

For the magnet upgrade, we could easily find an asset of a magnet, but what about a score multiplier? Well, that’s harder to find!

Specifically, how do we even represent a score multiplier power-up? The first thing that came to my mind would be the letters: “2X”.

I looked around and as I expected, I couldn’t find anything.

What are the options at this point? Well, there were a couple of things that came to mind:

  1. Create something with a 3D modeling software like Blender
  2. Make the object out of objects straight out of Unity.

I decided to go with option 1. I looked around and something neat that popped up was a free tool called Magica Voxel that helps create voxel art (think cube art like Minecraft).

Check out Magica Voxel.

The interface is simple, you’re essentially given a 40x40x40 workspace (where one cube is 1x1x1) and you can make anything you want by using these cubes.

Step 1.2: Creating the 2X multiplier with Magica Voxel

There were a couple of tools that you can use to help you make pretty amazing things that people have done with it.

You might not want to solely rely on Magica Voxel for a game (or at least without pairing the assets with other software), however for a quick prototype, it’s something we can easily and quickly create something for us to use.

The interface is straightforward:

On the left side, we have our color palette for our blocks. On the right side, we have our block options.

For the first set of options, I chose V for Voxel mode, which allows us to place cube individually in the workspace. There are 5 other options that we could use, but for our simple example, this is all we need.

Next, we have:

  • Attach – Create a cube by attaching it to a surface, either one of the surfaces or another cube.
  • Erase – Remove a cube from the workspace.
  • Paint – Re-color one of the cubes to your selected color.

As you can see, these are very simple bare-bone features, but as you can already see above, you could create some neat stuff with them.

Here’s the 2X power-up asset that we’re going to use that I spent 10 minutes making.

I was quite happy on how the 2 came out, but the X, not so much.

However, since this is just for an example, I really don’t care.

As you can see, it’s very straightforward to make an asset if you have an idea of what you want to make.

It doesn’t end just there though, I did some more research and if you created a character, you could easily integrate your model to use animations. For more on that, I recommend that you check out this great Youtube series:  MagicaVoxel Tutorial – Create, Animate & Import to Unity as FBX, to add animation to your voxel creation.

Step 1.3: Exporting the 2X power-up

Now that we have our 2X power-up, we need to export it to be in a format that Unity can use.

On the bottom right corner of Magica Voxel, there’s an export button.

  1. Click the export button and export it as an .obj.

When you export it, you’ll have three files.

The two files that we care about are the .obj file and the .png file. The .obj file is the model we want to use and the .png file is the texture that we need to apply to our game object.

Step 2: Adding our 2x Power-Up to Unity

Step 2.1: Exporting the Game to Unity

Now that we exported our asset, we need to import it to Unity.

  1. Drag and drop 2x.obj and 2x.png into our Unity project.

Now that we have our assets in our project, let’s use them.

  1. Drag 2x.obj into our game scene, you’ll see our 2X object in all its glory, but there won’t be any texture to it.
  2. To have the texture that we created in the game, we need to drag our png into our 2X object. This will apply our texture to the game object.

When we’re done, we’ll have something like this:

And that’s it! Before we move on to the next part of this series, we’re going to change this into a prefab that we can use.

  1. Drag the game object into our prefab folder. This game object will already be called 2X.

End of Day 89

That’s it! Today, we just created our own asset that we could use for our game using Magica Voxel.

For those who don’t want to follow along and make your own asset, I exported the 2X prefab so you can import it.

You can find the prefab from my project on Github. The file is called 2X PowerUp.unitypackage.

And that’s it! In the next post, we’re going to start adding our new score multiplier power-up into our game!

Day 88 | 100 Days of VR | Day 90

Home

The post Day 89 of 100 Days of VR: Endless Flyer – Creating A Multiplier Power-Up with Magica Voxel appeared first on Coding Chronicles.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)