[SOLVED] Unable to transition to next dialogue box

I’m currently creating a space game and in this scene the two characters have a dialogue with each other. Using the spacebar to trigger the first dialogue and second dialogue boxes. I was able to trigger the first dialogue boxes but when I press the spacebar again It will not transition to the second dialogue boxes. Below is my code.

// code here:
var Intro = pc.createScript('intro');

// initialize code called once per entity
Intro.prototype.initialize = function() {
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
this.Slide1Hero = this.app.root.findByName("Slide1Hero");
this.Slide1Image = this.app.root.findByName("Slide1Image");
this.Slide2Enemy = this.app.root.findByName("Slide2Enemy");
this.Slide2Image = this.app.root.findByName("Slide2Image");
this.Slide3Image = this.app.root.findByName("Slide3Image");
this.Slide4Image = this.app.root.findByName("Slide4Image");
slidecounter = 0;

};

// update code called every frame
Intro.prototype.update = function(dt) {

};
Intro.prototype.onKeyDown = function (event) {
    if (event.key === pc.KEY_SPACE && slidecounter == 1) {
        this.Slide1Hero.enabled = true;
        this.Slide1Image.enabled = true;
        this.Slide2Enemy.enabled = true;
        this.Slide2Image.enabled = true;
        slidecounter = 2;

    }
    
    if (event.key === pc.KEY_SPACE && slidecounter == 0) {
        this.Slide3Image.enabled = true;
        this.Slide4Image.enabled = true;
        slidecounter = 1;
    }
};

Hi @SuperSpace and welcome! It seems like you don’t disable the first dialogue when you enable the second dialogue, so could it be that the second dialogue is behind the first dialogue?

Hi, I disabled the first dialogue and saw that it was behind the first dialogue and changed around the organization of the dialogue names and it worked! Thanks for your help :slight_smile:

1 Like

Great! Thanks for your reply.