This post is currently awaiting moderation. If you believe this to be in error, contact a system administrator.
Question by
jretchford · May 13, 2020 at 12:51 PM ·
c#stringintconvertconversion
Having trouble converting this int to string, can someone help?
Fairly new to Unity, and I'm trying to write this piece of code in which if you have a certain money balance you can move onto the next scene, and if you don't you will go back and continue your quest for more money. The code I've currently wrote is here:
{
public GameObject guiObject;
public GameObject thoughtBubble;
public GameObject playerHead;
public GameObject text;
void Start()
{
guiObject.SetActive(false);
thoughtBubble.SetActive(false);
playerHead.SetActive(false);
text.SetActive(false);
}
void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
{
guiObject.SetActive(true);
if (FindObjectOfType<InventorySystem>().moneyDisplay = 400)
{
SceneManager.LoadScene("EndScene");
}
else
{
thoughtBubble.SetActive(true);
playerHead.SetActive(true);
text.SetActive(true);
}
}
}
void OnTriggerExit2D()
{
guiObject.SetActive(false);
}
The only issue I'm getting in my code is the conversion of the int to a string at the FindObjectOfType line. If anyone could help. I'd appreciate it a lot!
Comment
if (FindObjectOfType<InventorySystem>().moneyDisplay == "400")
{
Scene$$anonymous$$anager.LoadScene("EndScene");
}
Take note of the double == which means Is Equal