i would like to know how to make a day/night cycle in my game, it doesn’t have to be be complicated and it’s pretty self explanatory
Hello @Deadshot1m24,
Is this what you are looking for?
Take a look at this example…
https://playcanvas.com/project/920830/overview/day-night-cycle
https://playcanvas.com/editor/code/674858?tabs=29536303
check daynight cycle here it’s very simple
ok ketan i used your script, but can you make it like change the skybox, to where when it’s sunny its like a day with clouds skybox and when it starts turning nighttime the skybox changes like slowly same with the sky color
rn i put the speed to 0.1 so it’s slow, and realistic heres the project launch/link if you want to test it yourself
https://launch.playcanvas.com/1404359
@Deadshot1m24 Thanks
Skybox @ayrin using something like that already…
Game.prototype.daynight= function() {
this.timestart=Date.now();
if (this.hour==='day') {
this.hour='night';
this.cubenight.loadFaces = true;
this.app.scene.skybox=this.cubenight.resource;
this.app.scene.skyboxIntensity=0.3;
this.app.scene.fogColor=new pc.Color(0,0,0);
this.app.scene.fog='linear';
this.app.scene.skyboxMip = 1;
this.light.light.color= new pc.Color(0,0.1,0.3);
var lamp=this.app.root.findByTag('light');
var lamp1=this.app.root.findByTag('lamp');
for (var i=0; i<lamp.length;i++) {
lamp[i].light.enabled=true;
lamp1[i].model.model.meshInstances[7].material = this.texLamp[1].resource;
}
this.app.lightmapper.bake(null, pc.BAKE_COLORDIR);
} else {
this.hour='day';
this.cubemap.loadFaces = true;
this.app.scene.skybox=this.cubemap.resource;
this.app.scene.skyboxIntensity=1;
this.app.scene.fogColor=new pc.Color(0.3,0.4,0.5);
this.app.scene.skyboxMip = 1;
this.light.light.color= new pc.Color(0.7,0.7,0.7);
var lamp=this.app.root.findByTag('light');
var lamp1=this.app.root.findByTag('lamp');
for (var i=0; i<lamp.length;i++) {
lamp[i].light.enabled=false;
lamp1[i].model.model.meshInstances[7].material = this.texLamp[0].resource;
}
this.app.lightmapper.bake(null, pc.BAKE_COLORDIR);
}
};
The above code is from his script line no 156. He seems changing skybox…
Maybe you can do something like this…
can you put that into your day night cycle project since his doesn’t load for me and i want to see it in action
@Deadshot1m24 Sorry Not sure i can or not…
I recommend you take a look at code try a bit please…
If you never try you will never know…
Copy pasting will help to build the game but understanding will help you to build yourself!
i’m gonna work on it tommorow because i’m not working on my rpg rn i’m working on my racing game Plas-Go also if you can help with my other post about NITRO that would be great, i am quite thankful for you guys’s help though so thank you for all your hard work