So my plan is to create a dialogue text when the player hits a trigger box, the player has a script attached to it,
using UnityEngine;
using System.Collections;
public class PointerValue : MonoBehaviour
{
public static int pointerValue;
public int check;
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "dialogue")
{
pointerValue = saritacuteTrigger.valuePointer;
check = pointerValue;
}
}
}
this script will receive a value from the box it collided, the box have a script that contains the value
using UnityEngine;
using System.Collections;
public class saritacuteTrigger : MonoBehaviour
{
public int valueSetter;
public static int valuePointer;
public int check;
void Start()
{
valuePointer = valueSetter + valuePointer;
check = valuePointer;
}
}
the values from this script (attached to the box) will be the pointer or will tell the game what line from a text file should be displayed, here is the example of a text file.
<time/>000.020|<trigger/>0-Ugghhh... My head is aching, what time is it?-
<time/>030.129|<trigger/>1-Shit! It's past 5PM already!-
<time/>050.129|<trigger/>2-Well, fuck me right??-
<time/>080.129|<trigger/>3-
<time/>090.229|<trigger/>4-hsit-
<time/>100.229|<trigger/>5-what the fuck is wrong with this shit??!-
<time/>130.229|<trigger/>6-
the pointer i’m talking about is the numbers after the ‘< trigger / >’. that number will be the array number for the dialogue lines (sorry for the bad words, thats just random thought i had while doing this)
the main script the dialogue manager will get the value from the player’s script that contains the pointer, however, the dialogue manager is not accepting or receiving the said static value, here is the part where that should be happening:
public int triggerValue = saritacuteTrigger.valuePointer;
now this should where it counts to find the exact line given by the trigger box’s values received by the player.
//point to dialogue
if (nextSubtitle < subtitleLines)
{
if (GetComponent<AudioSource>().timeSamples/_RATE > subtitleTimings [nextSubtitle])
{
displaySubtitle = subtitleDialogue [tempTriggerValue];
nextSubtitle++;
tempTriggerValue++;
}
}
i can display my desired dialogue line from the array if I declare my public int triggerValue = saritacuteTrigger.valuePointer;
to public int triggerValue = "number for example 3"
.
I know this post is really long, but this is my first time developing a game, I really need help, what did i do wrong? i’m really lost. Thanks in advance, and please sorry for this long and probably wrong post but this is my first time posting here <3