Objective: Setting up and organizing the player!
We have created an environment using Tilemaps, We are ready to set up the player. We may have different sprites but you will be able to follow the steps below to bring the player into your 2D game!
I have a list of sprites that I need to slice and eventually animate them (that is for another time)
These are space in a way that we can use the automatic slice.
I have an idle animation. I will take the first sprite and drop it into the hierarchy.
I rename the sprite to “Sprite” and set the order in layers to 50. This is a quick way to guarantee the player will stay in front while we prototype our way through developing this game.
Something I want to be sure to cover in this tutorial is a fundamental best practice for handling typical artwork in a game. If we were prototyping primitive objects, we would typically create a player and attach that script to the object. I recommend isolating the model object from being cluttered.
This game is going to have several scripts, we don’t want to clutter up where my sprite renderer is. I want it to be nice and clean so that if we ever make an art change it’s very easy to swap in and out just the sprite and not have to worry about any of the other components.
Create and empty game object (CTRL + SHIFT + N) and name this “Player”
Set the position to 0,0,0
Child our Sprite object under the player object.
Select the sprite object and set its position to 0,0,0
Everything will be on the parent object (Colliders, scripts, etc.) and will access the child objects when we need them. This gives us a clean environment for our characters! Don’t be afraid to experiment with your character sprite and I’ll see you in the next tutorial!