Point light problem

Hello, i have a problem with the point light that make the lanter light in the village, i have set the start of the game in the village with 1,5 min for the day night cycle so you can notice that the light doesn’t affect the nearby objects and ignore the enable/disable function https://playcanvas.com/editor/scene/396696 start the game from editor and walk forward by clicking in the upper part of the screen and wait to see what i mean (just the table on the right shop seems to be affected by light…also in daylight when the light should be turned off).
this is the code

      daynight: function() {
            if (this.hour==='day') {
                this.cubenight.loadFaces = true;
                app.scene.fogColor=new pc.Color(0,0,0);
                app.scene.skyboxMip = 1;
                this.light.light.color= new pc.Color(0,0.1,0.3);
                var lamp=app.root.findByTag('light');
                for (var i=0; i<lamp.length;i++) {
                    lamp[i].findByName('Directional Light').enabled=true;
                    lamp[i].model.model.meshInstances[7].material = app.assets.find('orange','material').resources[0];
            } else {
                this.cubemap.loadFaces = true;
                app.scene.fogColor=new pc.Color(0.3,0.4,0.5);
                app.scene.skyboxMip = 1;
                this.light.light.color= new pc.Color(0.7,0.7,0.7);
                var lamp=app.root.findByTag('light');
                for (var i=0; i<lamp.length;i++) {
                    lamp[i].findByName('Directional Light').enabled=false;
                    lamp[i].model.model.meshInstances[7].material = app.assets.find('lambert1','material').resources[0];

Hi @ayrin, that is a nice game your building! Good job.

For your lighting issues, I think the issue is somewhere in your lighting properties:


You are using light mapped lights, but you set your light to affect only non-baked. Your scene is a bit heavy and it isn’t easy to fork and play with. But I imagine somehow your objects are excluded from being affect by lighting given those settings.

Try playing with the Lightmapped property on the surrounding models and set the light to affect the Baked models.

Now, regarding your day/night cycle, when using lightmapped lights and you make changes to your scene, you must rebake your lights in code. For example:

this.app.lightmapper.bake(null, pc.BAKE_COLOR)

Check here for more info on this method:

1 Like

Hi Leonidas and thanks for the tips, unluckly i have changed almost everything and nothing change, the light just have his effect on the table, i have cheched models and materials too, changed all the light options and tryed also with pc.BAKE_COLORDIR but my buildings are always in stealth mode lol

Can you create a simple sample project with just a few of these models and the same lighting settings, to play with?

Ok i try to do that

1 Like

Will need some time, need to find the models in the old hard disk :frowning:

Found the problem, don’t know why, but if i delete the light and add it again as new entity it works perfectly :smiley: EDIT: was because of the static flag

1 Like