Quantcast
Channel: Questions in topic: "skip"
Viewing all articles
Browse latest Browse all 85

button pressed twice / Conversation text skip

$
0
0

Hey guys,

I've got a really stupid problem...looked up the scripting reference & unity boards but didn't find a answer yet.

I'm trying to make a conversation between the player and a NPC (like in the most RPGs, running around and asking people).

Trigger, GUIs, everything fine & working until I want to skip the text with the same button!

So basically the player is colliding with the trigger-zone of the NPC. If inside and pressing the "Interact-Button" to talk, a text message appears. To skip the 1st part of the text and listen to the next, the same button is pressed again ("Interact-Button")

Here is my script which is attached to the trigger-zone (cube) around the NPC :


static var talking = false;
var TextA = false; 
var TextB = false;
function OnTriggerStay (other : Collider) 
{
    if(other.gameObject.tag == "Player")
    {
        if(Input.GetButtonUp("Interact"))
        {
            talking = true;
            TextA = true;
            print("TextA"); // console check
            if(Input.GetButtonUp("Interact"))
            {
                TextB = true;
                print("TextB"); // console check
            }
        }
    }
}
function OnGUI () 
{
    if (talking)
    {
        if (TextA) 
        {
            // GUI label is shown with Text A
        }
        else if (TextB)
        {
            // GUI label is shown with Text B
        }
    }
}

If I try to talk to the NPC and press the Button "ONCE"! the console shows me TextA followed by TextB immediately :( .

It should be like: press -> TextA -> press -> TextB ->press -> TextC and so on... [of course I would set the previous Text to false for it to disappear but first things first]

I would greatly appreciate your help Uni-Community


Viewing all articles
Browse latest Browse all 85

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>