Hi
I have trouble understaning why my script produces an error when I try to run it:
using UnityEngine;
using System.Collections;
public class RotatingCube : MonoBehaviour {
public float cubeSpeed = 5.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate(Vector3(0,1,0) * cubeSpeed * Time.deltaTime);
//gameObject.transform.Rotate(0,1,0);
}
}
The error(s) are:
Assets/Scripts/RotatingCube.cs(18,34): error CS0119: Expression denotes a type', where a
variable’, value' or
method group’ was expected
Assets/Scripts/RotatingCube.cs(18,27): error CS1502: The best overloaded method match for `UnityEngine.Transform.Rotate(UnityEngine.Vector3)’ has some invalid arguments
Assets/Scripts/RotatingCube.cs(18,27): error CS1503: Argument #1' cannot convert
object’ expression to type `UnityEngine.Vector3’
The errors only occur when I use this line of code:
transform.Rotate(Vector3(0,1,0) * cubeSpeed * Time.deltaTime);
but not when I use this:
gameObject.transform.Rotate(0,1,0);
It is also worth to note that the script runs fine in the video tutorial I watched
Using Unity 3 (game programming) - Rotations and Translations 1