Help with showing UI screens with hotspots

I’m looking some help with building a simple information player, I have a model that I want to place hotspots on and whenever I click them a modal or a screen appears from the side or wherever, not really important, but I want this screen to have some information and then buttons also that once clicked, the screen disappears and then I can click the next hotspot.

I have looked at the treasure chest example and did take the code but I cant figure out how to make the click event show a screen with what I want.

I have experience in html and css and I can read and understand Javascript but I’m new to PlayCanvas and still trying to understand how this all works and how to link things together.

Thanks

Hi @Crawford and welcome!

I’m not sure if it is exactly what you are looking for, but maybe the example project below can help you.

https://developer.playcanvas.com/en/tutorials/information-hotspots/

I copied this exact example but that’s pretty much as far as I got, I’m new to this and can’t seem to figure out how to make a click do something like bring up a screen with question and buttons.

I think this page below can help you with the next step.

https://developer.playcanvas.com/en/user-manual/user-interface/

https://developer.playcanvas.com/en/user-manual/user-interface/input/

Sorry I’m still having an issue trying to place the input script somewhere and also make some sort of screen appear.

I place the script but it’s showing there’s an error in the code I’m pasting, So I don’t think I’m placing the code in the right place.

Can you share the editor link of your project so I can take a look?

https://playcanvas.com/editor/scene/1678431

Not sure if that will work.

Your project has some errors, because your setup for the information hotspot is not the same as the example project.

If you want to use a button entity, like you do at the moment, you don’t need to use the scripts of the example project.

var ButtonLogic = pc.createScript('buttonLogic');

// initialize code called once per entity
ButtonLogic.prototype.initialize = function() {
    this.entity.button.on('click', function(event) {
        // enable information entity here
    }, this);
};

How or where do you want to show your information? In 3D space or a 2D screen?

want a 2d screen to appear from the side of the screen when a hotspot has been selected.

Something like this?

https://playcanvas.com/project/1045555

Yea something like that but I want the screen to only appear when the hotspot has been clicked

I update the project, but there seems to be a bug.

Do you want the 3D effect of the hotspots? Otherwise it can be easier with using a normal element entity.