Question by
gabstatem · Mar 13 at 02:43 PM ·
canvascountertransform.rotation
Coin flip counter
Im trying to make a 3d coin flipper that counts total flips, heads, and tails. Im pretty new to this so any help is 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 flipTextTwo;
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");
flipTextTwo.text = coin.transform.rotation.x.ToString("0");
int.Parse(flipText.text);
int.Parse(flipTextTwo.text);
if (flipText.text == "0")
{
landed = true;
}
else if (flipText.text != "0")
{
landed= false;
}
if (landed == true & coin.rotation.x == 90)
{
heads += 1;
Debug.Log("Heads");
}
else if (landed == false & coin.rotation.x == -90)
{
tails += 1;
Debug.Log("Tails");
}
//Debug.Log(flipText);
}
void flipTotal()
{
totalFLips += totalFLips;
}
}
Comment
Your answer