Sprites
Svep för att visa menyn
Sprites: Bringing Your Own Art Into Unity
In this video, you transform your endless jumper from a gray prototype into a real game by adding 2D art (sprites) for the player, platforms, and background.
From Prototype to Game World
- We return to our endless jumper project and replace the default placeholder sprite;
- This is where you decide the identity of your game:
- Who is the player character?
- What kind of world are they in?
- Your visuals don’t need to be perfect, simple drawings work great for learning.
What Is a Sprite?
- A sprite is a 2D image used in a game (characters, platforms, backgrounds);
- Sprites must have a transparent background, so they blend naturally into the scene;
- Because of this, sprites are usually saved as .png files.
Adding Existing Images as Sprites
- You can find ready-made sprites online (e.g. Google Images);
- When searching, include “png” and make sure the background is transparent;
- Save the image as a
.png, drag it into your Sprites folder, then into the scene.
Creating Your Own Sprites
- You can draw your own sprites using tools like Photopea or Piskel;
- You could also edit an existing image to add character to it;
- Export your drawings as
.pngfiles with transparency.
Platforms and Environment Art
- Platforms are also sprites and can be anything: bubbles, rocks, clouds, etc;
- You can add a floor platform if you want, but it’s optional.
Adding a Background
- Backgrounds are usually very far away and don't move independently.
- A simple approach:
- Add a background sprite;
- Make it a child of the Camera. Simply drag the background in the hierarchy onto the 'Main Camera';
- This ensures the background always stays visible as the camera moves.
Sprite Layering (Order in Layer)
- Sprites can overlap so Unity needs to know which one appears in front;
- You can control this using:
- Z position (within Transform), or
- Order in Layer (within Sprite Renderer)
A good rule of thumb:
- Background:
Order in Layer = -1; - Platforms:
Order in Layer = 1; - Player:
Order in Layer = 2.
Even with simple art, your game will now start telling a story. At this stage, visuals help motivate the mechanics we'll build next.
1. Which of the following best describes an image that is suitable to use as a sprite in Unity?
2. Why is a background sprite often made a child of the Camera in Unity?
3. Which setting tells Unity which sprite should appear in front when sprites overlap?
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 1
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Avsnitt 2. Kapitel 1