Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Sprites | Fundamentals of Components in Unity Inspector
Unity for Beginners

bookSprites

Pyyhkäise näyttääksesi valikon

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 .png files 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?

question mark

Which of the following best describes an image that is suitable to use as a sprite in Unity?

Valitse oikea vastaus

question mark

Why is a background sprite often made a child of the Camera in Unity?

Valitse oikea vastaus

question mark

Which setting tells Unity which sprite should appear in front when sprites overlap?

Valitse oikea vastaus

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 1

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Osio 2. Luku 1
some-alt