2D Galaxy Shooter: From Prototype to Production
Hello everyone, it’s another great day to start working on the next section of the game. I am to convert the prototype primitive objects into production assets!
The player, the enemy, and the projectiles are using primitive 3D objects. I need to convert to 2D sprites.
Converting from 3D to 2D
For me to convert, I drag the sprite that will replace the primitive 3D object into the parent of the Player, Enemy, and Projectile game objects. I then delete the primitive 3D object from the parent, which contained the Mesh Filter, Mesh Renderer, and Box Collider. In the parent, I delete the 3D components and replace them with their 2D versions. In this case, the Box Collider and Rigidbody are replaced by a Box Collider 2D and Rigidbody 2D.
Here’s an example of how I have my objects structured.
I use the parent for attaching components that affect the object. I then have child objects that pertain to the parent. In this case, I like to separate the sprite object from the parent. If I need to manipulate the sprite object, I can do so without altering the parent game object.
I hope this makes sense! If not, let me know and I can try to explain it better in some other post!
Script Changes
With the conversion of the assets going great, my collision detection stopped working. The reason is that I replaced the Box Collider and Rigidbody with their 2D counterparts.
I then needed to head into the Enemy script to change a couple of things.
The Enemy script communicates with the player and the projectile script using the OnTriggerEnter(Collider other)
function.
Since we are no longer using 3D assets, we need to convert OnTriggerEnter()
to OnTriggerEnter2D(Collider2D other)
.
Our collision detecting now works!
Conclusion
The quality of these assets is insane! With everything all together, it definitely looks like it’s starting to shape up into a polished game.
On the next progress update, we will look into power-ups!
Thank you for reading! :)