Ok, So I have a problem. (This may be a simple question…)
I want the script to display a string variable using TextMeshPro when the player touches a trigger, but it shows me these errors.
Assets\Scripts\AI.cs(19,12): error CS0619: ‘Component.collider’ is obsolete: ‘Property collider has been deprecated. Use GetComponent() instead. (UnityUpgradable)’
Assets\Scripts\AI.cs(19,34): error CS0029: Cannot implicitly convert type ‘UnityEngine.GameObject’ to ‘string’
Here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class AI : MonoBehaviour
{
[Header("Text and Setup")]
public TMP_Text dialougeText;
[Header("Trigger Settings")]
public GameObject trigger0;
[Header("Dialouge Settings")]
public string text0;
public void OnTriggerEnter(Collider other)
{
if(other.collider.name = trigger0)
{
Debug.Log("Trigger0 enter");
dialougeText.text = (text0);
}
}
}
What did I do wrong?