krzmig / godot-simple-sky-project

A simple Godot 4 project with day-night and season systems, a procedurally moving sun and moon, and a stylized sky shader.
MIT License
80 stars 4 forks source link

Change day_time while running #3

Closed HappyCringeDev closed 1 year ago

HappyCringeDev commented 1 year ago

Is there any way to change while the day_time while debugging / running the project. Because if you change the value "Day Time" in Main it will be overwrited after one frame.

By the way. I really like your shader. All the features and the beautiful athmosphere.

krzmig commented 1 year ago

Hi. You need to describe more precisely what you mean by this overwriting. I start the project and I can freely change the time of day in the editor and it doesn't get overwritten.

Nice to hear it, thanks :)

HappyCringeDev commented 1 year ago

Hey krzmig,

Thank you for the prompt reply. The situation is as follows:

I added your main scene into mine. In the external variables of your scene at the inspector, I changed the value "day_time" from 0.0 to 9.0. However, when I start the scene, the variable "day_time" switches back to 0.0. If I output the variable every frame, it shows that only for one frame the "day_time" is set to 9.0 before it gets reset to 0.0.

What I want to do is to set the sky time using the "day_time" value, and have the sky adapt to it and continue counting from there. That means, if I set "day_time" to 12.0 and start the scene, the sky should start at 12.0 and count up.

Thanks very much for your help in advance.

Best regards, Movv HCG

From Th., 2023 June 13 at 20:37 wrote krzmig @.***>:

Hi. You need to describe more precisely what you mean by this overwriting. I start the project and I can freely change the time of day in the editor and it doesn't get overwritten.

Nice to hear it, thanks :)

— Reply to this email directly, view it on GitHub https://github.com/krzmig/godot-simple-sky-project/issues/3#issuecomment-1589837118, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6S2TJDPPMKTMTYTOGAUZZLXLCXO7ANCNFSM6AAAAAAZBVBIIQ . You are receiving this because you authored the thread.Message ID: @.***>

pavanvo commented 1 year ago

I changed the value "day_time" from 0.0 to 9.0. However, when I start the scene, the variable "day_time" switches back to 0.0.

I had the same thing, I still don't know how to fix it.

HappyCringeDev commented 1 year ago

If you use the following function seek in the body script of the AnimationPlayer you can switch the time to something like 9 am. self.seek(9.0, true) (Not compatible with Day_of_year. Because it resets to the first day. And therefor not compatible with the clouds.)

krzmig commented 1 year ago

I added AnimationPlayer for demo purposes only. I think using it for something like time progression in the game is a bad idea. I removed it in the last commit. I added "Time scale" parameter in its place: obraz If you set the value to 1, the hour in the game will take a second. If 0.1, it's 10 seconds. If 0, the lapse will be disabled. If "day time" exceeds 24, "day of year" will increase by 1 and "day time" will reset.