Hey guys, I’m developing object inspection script
the idea is when I press (E) on the object, the dialog box appears, and take the first string and paste it into the text object in my scene, and if (E) is pressed again it puts the next string in the array, when the index is equal to the length of my array it comes out.
I have 2 problems, when he calls the first time he already adds 1 in the array starting in the second position.
it only exits after the array exceeded error occurs.
private void Update()
{
IndexPos();
if (Input.GetKeyDown(KeyCode.E) && trigger)
{
if (playerBark.activeInHierarchy)
{
if (more)
{
Use();
}
else
{
canUse = true;
playerBark.SetActive(false);
text.gameObject.SetActive(true);
return;
}
}
else
{
Debug.Log("First Use");
Use();
}
}
}
void IndexPos()
{
if(i != barkText.Length)
{
indexExist = true;
}
else
{
indexExist = false;
}
}
public void Use()
{
if (!canUse)
return;
if (indexExist)
{
Debug.Log("More Dialogues");
more = true;
i++;
playerBark.SetActive(true);
playerText.text = barkText*;*
}
else
{
Debug.Log(“Finish”);
more = false;
playerBark.SetActive(false);
}
}