Create a 2.5D plane


estimated time : 3 mn
ingredients needed : Unity
(this recipe is part of the footvolley game menu )

Detailed Steps

 

00:00 Creating a 3DPlane

Two possibility for creating a Plane GameObject :
By clicking on the top menu GameObject/3Dobject/Plane.
Or by right-click on the hierarchy panel and add 3Dobject/Plane.

00:10 Reset the gameObject position

It’s a good habit when you create a gameObject parent to reset it at a zero vector (0,0,0). Like this you always make sure to not make dumb placement mistakes.
It’s only after you made a reset position that you’ll start to play with the wanted position.
You can reset the position of a gameObject by clicking on the top right icon of it’s transform component.

00:16 Transferring an image into the asset library

Now we’ll take an image made especially for the game (all sprites are available for you to use when you join my exclusive patreon community), and drop it to the asset in our Images folder Unity project folder/Assets/Images (if you didn’t create the Images folder in the previous step setting up unity, you can do it now. Or never, It’s for clarity purpose only)

00:31 Importing an image as a Sprite

We need to set the image as a sprite, for this just click on the wanted image in the Images folder and in it’s Texture Type property change it to Sprite.

00:43 Adding a sprite component to the plane

By right clicking on the plane gameObject and add 2Dobject/Sprite.

00:57 Inserting the sprite

Drag and drop the wanted sprite in the Sprite value of the sprite component.

01:03 Rotate the sprite

What’s happening ? here you got a 2Dsprite component wandering in the wild of a 3D world, the 2D worlds only knows 2 axis(x,y), but the 3D worlds adds up the z axis, so we need to adjust a little.
Go into the transform component  of the sprite and set the X value to 90. With the default positioning of the 3D cam in Unity you either rotate the cam to get your wanted x and y views, or you just set up your mind (my easiest solution) that in a default unity 3D world, the Y axis is still the Y axis, but the X axis become the Z axis for 2D objects.

01:12 Disabling Mesh renderer

Trouble again, this overlapping texture is just the mesh renderer colliding with the sprite renderer, we don’t need the mesh renderer so let’s just disable it by clicking on it

01:25 Adjusting the camera

Okay everything is nearly set, play a little with the camera for adjusting your game view and your done.
One thing to clarify : let’s talk a minute about perspective and orthographic cameras.
In a 3D world the perspective camera is usually best suited, and the orthographic cam is for 2D mostly. So why are we playing with perspective cam while making a 2D game?
Essentially because we’re not really making a 2D game, but more a 2.5D one. We’re moving 2D sprite in a 3D world for this exemple.If you take a good look at the terrain sprite, it’s made with white lines in a square. On an orthographic cam you’ll see these lines with no deformation but playing with perspective spare me the work to draw diagonal lines to simulate perspective; and it’s even allow our player to get smaller as you go deeper in the terrain without coding a line (yes, you become lazy when you’re alone to work  :p ).

 

.

 

 

 

 

 

Leave a Reply