Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

A little help for a starter

Discussion in 'Editor & General Support' started by HMIMH, Oct 15, 2017.

  1. HMIMH

    HMIMH

    Joined:
    Oct 15, 2017
    Posts:
    7
    Hi guys, I'm following a tutorial but I guess it's a bit old, and I made this simple script to make a cube rotate, but it doesnt.

    using UnityEngine;

    public class Mover : MonoBehaviour {

    float deltarotation = 30f;
    // Use this for initialization
    void Start ()
    {

    }

    // Update is called once per frame
    void Update ()
    {

    }

    void rotate()
    {
    if(Input.GetKey(KeyCode.Q))
    transform.Rotate(new Vector3(0f, -deltarotation, 0f) * Time.deltaTime);
    else if (Input.GetKey(KeyCode.E))
    transform.Rotate(new Vector3(0f, +deltarotation, 0f) * Time.deltaTime);

    }
    }

    What am I doing wrong? Thanks!
     
  2. guzzo

    guzzo

    Joined:
    Feb 20, 2014
    Posts:
    79
    You never call the method rotate() in your script. I assume you want to do something like this:
    Code (csharp):
    1.  
    2. void Update ()
    3. {
    4.     rotate();
    5. }
    6.