I have this code here which is supposed to add 4 to the total score after the card gets placed down on a section named “Placement”. This script is on two other objects that are the same card.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PotatoScore : MonoBehaviour {
public int potatoTotal;
public bool isPlaced;
private void Start()
{
potatoTotal = 0;
isPlaced = false;
}
void Update ()
{
SetCostTotal();
Debug.Log(potatoTotal);
}
void SetCostTotal()
{
if (this.transform.parent.name == "Placement" && Input.GetMouseButtonUp(0) && isPlaced == false)
{
potatoTotal += 4;
isPlaced = true;
}
}
}
However, it will only add 4 for the first card that gets placed down. The other two cards don’t add 4 again like they should, even though isPlaced is still false for them. Why is this happening and what do I need to fix to get it to work properly?