Hy!
I’m making some kind of a board game where you have to collect letters. What I’m trying to do, is to display the collected letters, but it only shows me the first collected letter and after that, the next collected letters are only displayed in the Inspector. I don’t know where my mistake is so any advice is appreciated.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerController : MonoBehaviour {
public float speed;
public UnityEngine.UI.Text LitereColectate;
private string LitereleMele;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
LitereleMele = "";
LitereColectate.text = "";
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement*speed);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag=="Collect")
{
other.gameObject.SetActive(false);
LitereleMele = LitereleMele + other.gameObject.name;
LitereColectate.text = "Ai colectat: " + LitereleMele;
}
}
}