After looking for half an hour it seems like there is no simple explanation for what I’ve been doing wrong. I’m trying to make a purchasing system but it keeps saying I can’t use + or -.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Purchasing : MonoBehaviour {
public int Money = 500;
Inventory Inventory = Inventory.GetComponent<Inventory>();
public void Marine(){
Money = Money - 100;
Debug.Log ("-100 Money");
Inventory.Marine = Marine + 1;
Debug.Log("+1 Marine.");
if (Money < 0) {
Money = Money + 100;
Debug.Log ("Not Enough Money!");
Inventory.Marine = Marine - 1;
Debug.Log ("Marine RESINDED.");
}
}
public void Assault_Rifle(){
Money = Money - 100;
Debug.Log ("-100 Money");
Inventory.Assault_Rifle.Add(1);
Debug.Log ("+1 Assault Rifle");
if(Money < 0) {
Money + 100;
Debug.Log("Not Enough Money!");
Inventory.Assault_Rifle = Assault_Rifle - 1;
Debug.Log ("Assault Rifle RESINDED.");
}
}
That is the first script the main one the second one is here.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Inventory : MonoBehaviour {
public float Pistol = 0;
public float Assault_Rifle = 0;
public float Marine = 0;
void Start () {
}
// Update is called once per frame
void Update () {
}
At the end I changed it to a float thinking it might work better using floats.