Spinning Cube

Checked with version: 3.5

-

Difficulty: Beginner

-

Date: 12 Mar 2014

The most basic of Unity challenges to get you started in coding - how to make a spinning cube. Download Assets

Spin

Code snippet

using UnityEngine;
using System.Collections;

public class Spin : MonoBehaviour
{
    public float speed = 10f;
    
    
    void Update ()
    {
        transform.Rotate(Vector3.up, speed * Time.deltaTime);
    }
}
#pragma strict

public var speed : float = 10f;


function Update ()
{
    transform.Rotate(Vector3.up, speed * Time.deltaTime);
}
import UnityEngine
import System.Collections


public class Spin(MonoBehaviour):

    public speed as single = 10.0F

    
    
    private def Update():
        transform.Rotate(Vector3.up, (speed * Time.deltaTime))
Simple Clock

Related tutorials

Translate and Rotate (Lesson)

Related documentation

Transform Rotate (Script Reference)