I know this is a frequent issue, but here’s the code:
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour {
int CameraMovementSpeed = 2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Transform.Translate (0, 0, CameraMovementSpeed);
}
}
I’m new to Unity and C#, in fact my only experience is in basic C++ programming.
I have two questions:
-
Why isn’t this working? I’m trying to mimic this javascript version: Unity 3D: Introduction to Scripting - YouTube
-
Why does it all have to be in class brackets? Can’t it look like this instead? (Here it even complains about the “int CameraMovementSpeed = 2;”)
using UnityEngine;
using System.Collections;int CameraMovementSpeed = 2; // Update is called once per frame void Update () { Transform.Translate (0,0,CameraMovementSpeed); }