[SOLVED] Problem with using 'visibleThisFrame'

I have a problem with using visibleThisFrame. It works for me when the entity is outside the screen, but not when the entity is behind another entity. Probably thats just how visibleThisFrame works, but I want to know if the player can see the entity. Any idea?

see here on how this works

I used the forum topics to set it up, and it’s working when the entity is outside the screen but not when the entity is behind another entity.

image

    // Set visibility
    this.app.scene.layers.getLayerByName("World").onPostCull = (cameraIndex) => {
        if (this.target.model.meshInstances[0].visibleThisFrame) {
            this.entity.element.enabled = false;
        } 
        
        else {
            this.entity.element.enabled = true;
        }
    };

Ah I see. Well, Playcanvas does not do any occlusion visibility checking … so this flag only indicates that entity is within the view frustum.

for visibility between players you need to use different means …perhaps casting few rays to see if they can reach the other player.

Ah okay, then I know it’s working as it should be! Thanks for your input @mvaligursky!

2 Likes