Hello guys. I've made simple combo system but I'm getting strange error. Code (CSharp): if (other.gameObject.tag == "Player") //if hit confirm box collided with player { comboTextTemp = Instantiate(comboText, other.transform.position, Quaternion.identity); comboTextTemp.GetComponent<TextMeshProUGUI>().text = player.combo.ToString(); } It says that comboTextTemp is never assigned and I cant use it. For me everything seems fine What may be a solution?
It's strange, because IT IS assigned because I can controll it's position. This works fine: Code (CSharp): if (other.gameObject.tag == "Player") //if hit confirm box collided with player { comboTextTemp = Instantiate(comboText, other.transform.position, Quaternion.identity); //comboTextTemp.GetComponent<TextMeshProUGUI>().text = player.combo.ToString(); comboTextTemp.transform.position += new Vector3(2, 0, 0); }
Well. Ok. Sometimes you need to describe problem to solve it yourself. In GetComponent use TextMeshPro instead of TextMeshProUGUI