I’m making a 3d coin flipping game and am getting stuck trying to get my counter to count how many times the coin has landed on each side and the total flips, it will continuously count when the coin is head’s up, but nothing happens when the coin is tail’s up.
Any help would really be appreciated
using
UnityEngine;
using UnityEngine.UI;
public class ScoreTracker : MonoBehaviour
{
public int totalFLips;
public int heads;
public int tails;
public Transform coin;
public Text flipText;
public Text flipCount;
public bool landed;
// Start is called before the first frame update
void Start()
{
totalFLips = 0;
heads = 0;
tails = 0;
}
// Update is called once per frame
void Update()
{
flipText.text = coin.transform.position.y.ToString("0");
//flipCount.text = coin.rotation.eulerAngles.x.ToString("0"); // !!!the landed bool works as intended if this is commented out!!!
int.Parse(flipText.text);
int.Parse(flipCount.text);
if (flipCount.text == "0")
{
flipTotal();
}
else
{
flipTotal();
}
//Debug.Log(flipText);
}
void flipTotal()
{
if (flipCount.text == "0") //if coin is on the ground lanned is set to true
{
landed = true;
}
else //if coin is not on ground Landed is false
{
landed = false;
}
if (landed & coin.rotation.eulerAngles.x == 90) //This counts up continuously when the coin is head up
{
heads++;
Debug.Log("Heads");
}
if (landed & coin.rotation.eulerAngles.x == -90) //This does not count and i do not understand why
{
tails++;
Debug.Log("Tails");
}
}
}