Advertisement
electricmaster

Unity Spinning Cube

May 13th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Spinner : MonoBehaviour {
  5.  
  6.    public  GameObject cubespinner;
  7.     // Use this for initialization
  8.     void Start () {
  9.         cubespinner = GameObject.Find("Cube");
  10.     }
  11.    
  12.     // Update is called once per frame
  13.     void Update () {
  14.         if (Input.GetKey(KeyCode.LeftArrow))
  15.         {
  16.             cubespinner.transform.Rotate(0, 0, 60 * Time.deltaTime);
  17.         }
  18.         if (Input.GetKey(KeyCode.RightArrow))
  19.         {
  20.             cubespinner.transform.Rotate(0, 0, -60 * Time.deltaTime);
  21.         }
  22.         if (Input.GetKey(KeyCode.DownArrow))
  23.         {
  24.             cubespinner.transform.Translate(0, -10 * Time.deltaTime, 0);
  25.         }
  26.         if (Input.GetKey(KeyCode.UpArrow))
  27.         {
  28.             cubespinner.transform.Translate(0, 10 * Time.deltaTime, 0);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement