Below you can see our warrior. When he swings his sword, we see a cool arcing effect that makes the scene more visibly pleasing. Here I will go through the steps to add this.
The first thing to do is to add a sprite to the player game object, here I will call it Sword_Arc.
In the above scene, we see animated waterfalls. These are essentially special tiles that animate through several different frames, each frame being a separate sprite. How do we create this? It’s not that hard.
The first thing that needs to be done is to download the Unity 2d extras repository from Github. Go here: Unity-Technologies/2d-extras: Fun 2D Stuff that we’d like to share! (github.com)
Here, I will demonstrate how to flip a sprite across its X axis in Unity, using the sprite renderer’s flip X property.
Below, we have our character’s sprite facing to the right. This was how the sprite was originally drawn and it should look this way when imported into a project:
Now if we move to the right, there are no problems. He moves and animates as he should when he moves to the right:
In the above scene, I’d like to use a Physics2d Ray Cast to determine if the player is on the ground or not. If the ray strikes the ground where the player is standing then the player is grounded. Below you can see that there are composite colliders on each of the platforms.
Here I will demonstrate how to use the sprite editor to slice up an image into individual sprites. The image below is one .PNG file meant to be used as terrain tiles:
After importing it into Unity, we need to change the sprite mode to Multiple. . If you want to learn about some of the other settings look here: Unity — Manual: Texture Import Settings (unity3d.com).
Adding a collider to your Unity tile map is extremely easy and can be done in a couple of steps. This short article will demonstrate the process.
First add a tilemapcollider2d component to your tilemap with the add component button in the inspector. You can see what this does below:
What has happened is that every tile on the tilemap receives its own collider. It would be better if we had one collider that was a composite of all the tiles in the tilemap. This can be done by adding a compositecollider2d component to your tilemap like so:
Let’s talk about parallax for a few minutes. What is Parallax? It’s basically a technique where background images move slower than foreground images, which gives an illusion of depth in a 2D scene. Early parallax scrolling has been seen in video games since the early 80’s. The original technique goes back to1930’s animation techniques.
Basically what is happening in Parallax is that you have separate background layers moving at different speeds. The closer layers move more quickly than the farther layers.
The Unity Engine makes it very easy to set up a parallax effect with just a few changes to…
Here I will discuss the steps I use to create a tile palette in Unity from a 2d image.
First lets get the image file ready by slicing it up. The particular image I’m going to use represents ground tiles, each one is 16 X 16 pixels. In order to get started, you need to select the image and change sprite mode to Multiple. Next, I change the pixels per unit to 16, so that each tile will represent one unit in the world. After that, I use the sprite editor to slice the pixels.
In the sprite editor, under…
Here I will go over how to get a basic tile map up and running in Unity.
First create a tile map game object:
Above I set up a basic rectangular tile map. This is done by right clicking in the hierarcy and then clicking: 2D Object -> Tilemap ->Rectangular. There are several options, including hex and isometric, but here I will choose a basic rectangular grid.
Below you can see what this gives me:
Here I will go over how to modify your project to use the Universal Rendering Pipeline (URP) in Unity, if you did not initially set your project up to use it.
Our character below who shows up in pink is currently using a URP material. The other scene items are using standard materials and are currently being rendered properly.
The first thing you might need to do is to download and install the URP. This is done through the package manager. Click on Window -> Package Manager, search for Universal RP. Click on install in the lower right. …