Text doesn't update correctly
So I've been working on my project recently, I was going to add a Wall Buy System (similar to COD Zombies) and everything it's working fine besides the UI.
I have a raycast that looks at an Wall Buy object with the tag "WallBuy" and display a message saying which weapon the player is buying and how many points it requires, but the problem is in play mode, when there's 2 Wall Buy objects with both the tag "WallBuy", only the first one that was added to the scene displays a message, but all the code for the message works (code below)
string _text = "Press F to buy " + "(" + Manager.weaponList[index].WeaponIndex + ")" + Manager.weaponList[index].WeaponName + " for " + Manager.weaponList[index].pointsToBuy;
full code:
void Update()
{
if (...)
{
(...)
if (Physics.Raycast(eyesPoint.position, eyesPoint.transform.forward, out RaycastHit hit))
{
//Debug.Log(hit.transform + "/" + hit.transform.tag);
if (hit.transform == obj && obj.tag == "WallBuy" && hit.distance < 2)
{
Debug.Log(transform.name + " / " + Manager.weaponList[WpnIndex].WeaponIndex + " / " + WpnIndex + " / " + Manager.weaponList[WpnIndex].WeaponName);
this.Buy(this.WpnIndex);
}
else
{
text.text = "";
}
}
}
}
void Buy(int index)
{
string _text = "Press F to buy " + "(" + Manager.weaponList[index].WeaponIndex + ")" + Manager.weaponList[index].WeaponName + " for " + Manager.weaponList[index].pointsToBuy;
if (isUsed != true && Manager.weaponList[index].isBuyable != false)
{
if(text.text == "")
{
text.text = _text;
}
Debug.Log(text.text);
}
capture2.png
(17.1 kB)
Comment
Your answer
