#pragma strict
var talkLines:String[];
var talkTextGUI:UnityEngine.UI.Text;
var textscrollSpeed:int;
private var talking:boolean;
private var textIsScrolling:boolean;
private var playerScript:UnityStandardAssets.Characters.FirstPerson.FirstPersonController;
private var currentLine:int;
function OnTriggerEnter(col:Collider){
if(col.tag == "Player"){
playerScript = col.GetComponent(UnityStandardAssets.Characters.FirstPerson.FirstPersonController);
Debug.Log(playerScript);
talking = true;
currentLine = 0;
//talkTextGUI.text = talkLines[currentLine]; //STATIC
startScrolling();
playerScript.enabled = false;
}
}
function Update () {
if(talking){
if(Input.GetButtonDown("Npcmt")){
if(textIsScrolling){
//display full line
talkTextGUI.text = talkLines[currentLine];
textIsScrolling = false;
}
else{
//display next line
if(currentLine < talkLines.Length - 1){
currentLine++;
//talkTextGUI.text = talkLines[currentLine]; //STATIC
startScrolling();
}
else{
currentLine = 0;
talkTextGUI.text = "";
talking = false;
playerScript.enabled = true;
}
}
}
}
}
function startScrolling(){
textIsScrolling = true;
var startLine:int = currentLine;
var displayText:String = "";
for(var i:int = 0; i < talkLines[currentLine].Length; i++){
if(textIsScrolling && currentLine == startLine){
displayText += talkLines[currentLine]*;*
talkTextGUI.text = displayText;
yield WaitForSeconds(1/ textscrollSpeed);
}
}
}
Above is my NPC talking script in Unity.
#pragma strict
var script : NPCscript;
function Start() {
script = GetComponent(NPCscript);
script.enabled = false;
}
Above is my disabling script for the NPC script. The problem is that when I disable the script it doesn’t fully work and it shows the first line of dialogue and you can’t continue the dialogue. I want all the dialouge to be fully disabled and not to work. The variable talking and the variable textIsScrolling become true when the script is disabled when I talk to the NPC and I think that that is the problem.
Thanks, ~Jordan
P.S Both of these scripts are in JS.