I am trying to create a conversation system between a player object and another NPC object. So far it works. When i enter the NPC trigger and press the mouse button down, it will scroll through the dialogue i’ve assigned in the inputField array, the biggest issue I potentially see with this is the following line:
NPCtext.text = inputField[conversation];
I am performing this code in the update function, so i’m not sure if this is performing unnecessary calculations. So my question is, is there a more efficient way to put my code? Or am I on the right track with this? Regards
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class showText : MonoBehaviour
{
void Update ()
{
if (Input.GetButtonDown("Fire1"))
{
conversation+=1;
}
NPCtext.text = inputField[conversation];
}
void OnTriggerEnter(Collider collide)
{
input.active = true;
cam.active = true;
}
void OnTriggerExit()
{
NPCtext.text = "";
input.active = false;
cam.active = false;
}
}