Hi, I want to change Environment settings in my Script, because I want to make post processings effects when Nitro is enabled. I tried changing the Environment, but that caused performance issues. Is there a way to change the Settings from script, or load both envirovements at the beginning, so that it can seamlessly switch between those? Thanks for help!

Welcome to the forums @XORByte!

I have not tried it myself, but something like this may work:

extends WorldEnvironment

export (Environment) var normal_env
export (Environment) var nitro_env

func _ready():
	environment = normal_env

func change_to_nitro():
	environment = nitro_env
func change_to_normal():
	environment = normal_env

The exported variables can then be set from the Godot editor the environment for normal and nitro mode, and then you can swap between them using the functions change_to_nitro and change_to_normal.

Thank you! I havn't tried it yet,but as soon as i have, i will post here if it has worked.

Ok, it has actually worked, wich actually suprised me, beacause I did the same thing with environment = load("path/to/environment.tres") in the change_to_nitro function, but with this I had Performance issues. But when I now think about it, it propably was because he was loading the environment every time when I wanted it to change. If this is true, I should be able to get the same Result as in your Code by loading the Environments into a Variable by var env = load(path/to/environment.tres) and then acsesssing it with the same code you have in the change_to_... functions. The best way would probably be, to direcly change the Values in the recource from script, so that it is possible to smoothly change the post processing values from one to another. So if someone knows how to do that, please Post it here, and also huge thanks to @TwistedTwigleg

Ok, that worked! Sometimes I just forget about the most obvious things...! Thank you!

2 years later