- Tutoriels
- 2D UFO tutorial
- Creating Collectable Objects
Creating Collectable Objects
Vérifié avec version: 5.2
-
Difficulté: Débutant
In this assignment we'll add collectable objects to our 2D UFO game in progress. We'll use Prefabs, 2D trigger colliders to do this, and add a one line C# script to make the collectable objects rotate.


Creating Collectable Objects
Débutant 2D UFO tutorial
Code snippet
using UnityEngine;
using System.Collections;
public class CompleteRotator : MonoBehaviour {
//Update is called every frame
void Update ()
{
//Rotate thet transform of the game object this is attached to by 45 degrees, taking into account the time elapsed since last frame.
transform.Rotate (new Vector3 (0, 0, 45) * Time.deltaTime);
}
}
Tutoriels apparentés
- Introduction to 2D UFO Project (Cours)
- Setting Up The Play Field (Cours)
- Controlling the Player (Cours)
- Adding Collision (Cours)
- Following the Player with the Camera (Cours)