Creating Collectable Objects

Checked with version: 5.2


Difficulty: Beginner

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

Beginner 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);