Description
The FogStrength
property of the Light
class in the Sandbox API is used to control the intensity of the fog effect associated with a light source. This property is a floating-point value that ranges from 0 to 1, where 0 means no fog influence and 1 means full fog influence.
Usage
To adjust the fog strength of a light, set the FogStrength
property to a value between 0 and 1. This can be done programmatically within your game logic to dynamically change the fog effect based on game conditions or player interactions.
The property is decorated with several attributes:
PropertyAttribute
: Marks this as a property that can be exposed to the editor.
MakeDirtyAttribute
: Indicates that changes to this property should mark the object as "dirty," prompting a refresh or update.
RangeAttribute
: Specifies the valid range for this property (0 to 1) and the increment step (0.01).
CategoryAttribute
: Categorizes this property under "Fog Settings" in the editor.
DefaultValueAttribute
: Specifies the default value for this property.
Example
// Example of setting the FogStrength property
Light myLight = new Light();
myLight.FogStrength = 0.5f; // Sets the fog strength to 50%
// Adjusting fog strength based on game conditions
if (isFoggyWeather)
{
myLight.FogStrength = 0.8f; // Increase fog effect
}
else
{
myLight.FogStrength = 0.2f; // Decrease fog effect
}