Abshire
3 min readDec 11, 2022

TURNING 2D ENEMY INTO 3D ENEMY!

first thing you want to do is in go to your enemy prefab and click on your enemy and you will see in the inspector it has a mesh renderer, rigid body, and a box collider for this purpose we are going to delete those components and all that should be left is the Enemy script and the transform, like so.

(The box collider is currently using a 3D collider and a 3D rigid body component and we don't need that since this is a 2D game so that's why we remove it.)

WE then add a Box collider 2D to the Player and Enemy.

Now we need to turn this Enemy into a Sprite.

We now need to add a component of ( Sprite renderer)

You will see that is has no Sprite source or it is looking for. Now we could simply do the same thing we did to the player in the steps on how to add our sprite to the player but this is just another way so you can see the sprite as a component. so we take a look into our Sprite folders and drag the (Player_Turn_left) as the Sprite source and we will see our enemy now the way we want it same as our player. (Don't forget to add the sorting Layers)(Foreground layer)

Now remember we need at least the player or the Enemy needs to have a rigid body and in this our Enemy had the rigid body so go ahead and add a (rigid body2d) to our Enemy as a component.

Also make sure the gravity scale it set to 0 so we don't apply gravity, we are controlling the player threw script we don't need gravity. We just need the Rigid body2d for the collision.

The last thing we need to do for our Enemy is we need to add a (2D Box collider) we did have one before but that for 3d and since it is a 2D game we are making we need it to be 2D. ( Remember also we are not looking for a trigger Collison so the Trigger in the Box collider needs to be checked).

We also want to add on a 2D Box collider to our Player as well.

You can see now we have our player an enemy the way we want but you will also noticed there is no collision to the laser being able to hit the enemy nor can the enemy hard the player on collision. that is because in our (OnTriggerEnter) method in our Enemy script and we just add 2d to our (OnTriggerEnter) and our (Collider other) like so.

After all that we should be good to go and see that we now have out enemy the way we want it to look and our player and the enemy can still take lives away from the player when it collides.

Abshire

Just a Game Developer who is not afraid to push boundaries.