There two problems when using the hotspot, are they bugs?

Please refer to the following link of the project to reproduce the problems easily,
https://playcanvas.com/project/1269615/overview/information-hotspots

The first issue, the hotspot can’t be showed by tween changed position.
step 1,
button “show2”, set “Anim Show?” true, and the hotspot2, set ‘Enable fade’ true.

step 2,
launch the project,
click the button ‘show2’, the hotspot2 can’t be showed.

if the button “show2”, set “Anim Show?” false, or the hotspot2, set ‘Enable fade’ false.
The hotspot will show correctly.

The second issue, the hotspot can’t be clicked normally when showed by tween position.
step 1,
button “show3”, set “Anim Show?” true, and the hotspot3, set ‘Enable fade’ false.


step 2,
launch the project,
click the button ‘show3’, you can see the hotspot3, but click it has no response.

I think maybe the entity.position() of the hotspot3 didn’t be updated, you can click the shere(the origin position of the test3), the hotspot3 could be triggered.

So I tried add the code to update the position of the hotspot, then it can be triggered normally.
I use the setTimeOut 1000, means to wait the animation acompolished.

Thank you in advance, please help to find out the problems or are they bugs?

Hi @goinix_project. It is difficult to understand the problem with these many screenshots and very little text. Can you simply write down your problem? I’ll be glad to help you

Thanks for your help,
The first problem, the hotspot2 can’t be seen when click the “show2” button to enable the “test2” entity and it’s children.

The second problem, the hotspot3 can’t be clicked normally when click the “show3” button to enable the “test3” entity and it’s children.

@goinix_project a quick fix is that you should not disable the entities ‘test2’ and ‘test3’ in the start and disable them on postinitialize of a script. In this way when you enable them again they will work fine.

Check this project: PlayCanvas 3D HTML5 Game Engine

I added disableAfterInitialize Script for this purpose on Root.

1 Like

Thank you @Faiq_Laiq for your suggestion. I have tried an other way to add the code to update the position of the hotspot, then it can be triggered normally.
I use the setTimeOut 1000, means to wait the animation completed.
I just want to know the reason, if they are bugs or not?

image

Using setTimeout for delaying tasks is generally not recommended, especially if the browser may be minimized or inactive. This is because setTimeout continues counting time even when the browser is minimized, leading to unexpected behavior or resource usage.

In PlayCanvas, instead of using setTimeout directly, you can leverage PlayCanvas’s built-in timing mechanisms, which work well within the engine’s update loop.

Set up a timer variable that counts down in the update function, ensuring the timer only progresses when the game is active.

MyScript.prototype.initialize = function() {
    this.timer = 5; // 5 seconds
};

MyScript.prototype.update = function(dt) {
    if (this.timer > 0) {
        this.timer -= dt;
        if (this.timer <= 0) {
            // Timer completed action here
        }
    }
};

Yes, it’s a good idea. Thanks

@yaustar @LeXXik
Hi guys, please have look at these issues, are they bugs?