GameDev : revert project from 3D to 2D (Part II)

Matteo Lo Piccolo
3 min readMay 30, 2021

Is time to change Player.
The easiest way to do this is simply rename our SpaceShip to Player

And attach Player script component on it.
This because we can use EVERYTHING WE WANT and call it Player : a cube, a sphere, a cylinder or a beautiful 3D or 2D arts.
The only thing gives it the behaviour is the script.

We can drag and drop the script Player

But we need to reset some value and drag and drop again the prefab

Or we can COPY DIRECTLY that component

The same component copied. And each value is already set.

There is no right or wrong way, either is absolutely valid.

Now we can delete the cube as Player from scene,

Delete cube Player

and test it

Our Spaceship don’t collide with enemy

We have a couple of problems here.
One is really simple, we have to change scale of Spaceship, so we just change scale from 1, 1, 1 to 0.5

The second problem is that our Ship not collide with Enemy.
Why?
Because now our Player is 2D, is a SPRITE, but the rest of things are 3D object.
We have to change some logic to make collide Player and Enemy.

We have Enemy prefab.
I open it

This is our Enemy

Now, what we have to do here is change this object from 3D to 2D, right?

In Inspector, we remove all the components we don’t need.
Start with RigidBody, because this RigidBody is 3D RIGIDBODY, we need a 2D RIGIDBODY.
Remove BOX COLLIDER for the same reason of RigidBody.

Continue with MESH RENDERER and CUBE (Mesh Filter)

Enemy with script

If I now put an enemy on Scene, we will have a simple empty GameObject

This because we remove the Mesh Renderer of Enemy.
But we need it.
But because this is a SPRITE 2D, we need a SPRITE RENDERER
So we add the component, Sprite Renderer

Here we have the space to add a sprite

In my project, I have this sprite and add it to Sprite Renderer

We make a test

Enemy works fine, but doesn’t have Collision yet.

In the next part we fix the Collisions!

--

--

Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!