Here is my current script. I need create script(with properties) so when i pick up item it must display it name on UI text. But my current script doesent work,how to solve it? (i must use properties)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class BaseItem : MonoBehaviour
{
private Collider Other;
private string _name;
public string Name
{
get
{
return _name;
}
set
{
value = Other.gameObject.tag;
_name = value;
}
}
public TMP_Text displaytext;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Item"))
{
Other = other;
BaseItem item = new BaseItem();
displaytext.text = item.Name;
Destroy(Other.gameObject);
}
}
}