Assign a Component

Let’s build onto our Player GameObject by assigning our first Component. We already have the Transform Component to determine its point in 3D space but nothing to define the look of it. As our game will be a 2D platformer, it makes sense that we should create our player as a sprite.

1. If not already selected, make sure you have the Player GameObject selected. Again, you can check the Hierarchy or Inspector to make sure of this.

2. Click the Add Component button at the bottom of the Inspector and select Rendering > Sprite Renderer. In the Inspector, the Sprite Rendered Component should now be attached to our Player GameObject.

3. We can now add our sprite asset to our new Component. In the Inspector, click the small target ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.