So, I'm playing around with some C# code in Unity for the first time. I'm creating a little script just to dink around with, not for actual use. This is the error I get:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
public int speed = 10;
public int money = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.W)) {
transform.Translate (Vector3.forward * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.A)) {
transform.Translate (Vector3.left * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.S)) {
transform.Translate (Vector3.back * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)) {
transform.Translate (Vector3.right * speed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.Return && money >= 10)) {
Debug.Log("You bought a sword!");
money - 10;
} else {
Debug.Log("You don't have enough money!");
}
}
}
The error I get is in the title. It won't even let me run it. Does anyone know what I did wrong? Thanks for any help : )