[SOLVED] How to create a task progress bar?

this.entity.translateLocal(5*dt, 0, 0);

That will make progress go at the same speed no matter what device?

As far as I know, yes.

Thank you so much! the next part of the code in my old game was

    if (proggressCount > 6100) {
        this.ProggressText.enabled = false;
        this.ProggressBar.enabled = false;
        this.ProggressTank.enabled = false;
        this.Text.enabled = false;
        this.Lock.enabled = false;
        this.entity.enabled = false;
        Completed = 1;
        console.log(Completed);
    }

But is there a way to detect position without a progress count variable?

Something like this?

if (this.entity.getLocalPosition().x > 10) {
    // progress complete
}

You can adjust the value.

1 Like

Do you know how to do random spawns? like of all the trash cans only one has a “key”?
Btw thank you so much, of all the great people I met on playcanvas I learned the most from you :slight_smile:

Thank you very much! :star_struck:

There is a getRandomDestination function in the Basic enemy AI project, that you can use as example.

Maybe but I just got a small idea and want your thoughts on it. So when the game starts I do a mathRandom thingy (not 100% sure what the command is) on a global variable, the number will be from (lets say there are 4 trash cans) 1 - 4 and lets say on one of the trashcans there is a added to completion script that goes something like if (global variable = 2) then give player key

You might understand more when you see how “looting” trash cans work
https://launch.playcanvas.com/1903823?debug=true&ministats=true

I don’t think a random spawn will work as you don’t want it to spawn inside another object?

The “key” is not a object

Ah I see, I misunderstood.

You can create an array of your trash cans and then pick randomly one from the array. Activate the key in the script of that trash can.

I don’t know the code offhand.

1 Like

I think I can do it with the playcanvas math random, can you tell me it please?

No I can’t, because I don’t know offhand.

I need to search on the forum and Google as well.