ImprovedWeatherEffect
ImprovedWeatherEffect is a ScriptableObject that defines the visual and behavioral aspects of a weather in Lethal Company. It serves as the core component for both vanilla and custom weather effects.
ImprovedWeatherEffect manages the GameObject references and properties that make up a weather effect’s appearance and behavior.
Properties
Section titled “Properties”GameObjects
Section titled “GameObjects”EffectObject
Section titled “EffectObject”The GameObject that is visible only to the player. This typically includes:
- Rain particles
- Sound effects
- Screen effects
- Other client-side visual elements
WorldObject
Section titled “WorldObject”The GameObject that is placed in the world and visible to all players. This typically includes:
- Floodwater
- Lightning bolts
- Fog volumes
- Other world-space elements
Configuration
Section titled “Configuration”SunAnimatorBool
Section titled “SunAnimatorBool”The name of the sun animator’s bool parameter that gets toggled when the weather effect is enabled.
Vanilla values:
""(empty) - Clear weather"overcast"- Stormy/Flooded weather"eclipse"- Eclipsed weather
DefaultVariable1 & DefaultVariable2
Section titled “DefaultVariable1 & DefaultVariable2”Default weather variables used by the game’s weather system. These correspond to the weatherVariable and weatherVariable2 fields in vanilla’s RandomWeatherWithVariables.
State Properties
Section titled “State Properties”EffectEnabled
Section titled “EffectEnabled”Controls whether the weather effect is currently active. Setting this property will:
- Enable/disable the
EffectObject(if player is not inside) - Enable/disable the
WorldObject - Update the TimeOfDay weather effect state
EffectActive
Section titled “EffectActive”Read-only property that returns whether the EffectObject is currently active.
LevelWeatherType
Section titled “LevelWeatherType”The vanilla weather type enum value associated with this effect.
VanillaWeatherEffect
Section titled “VanillaWeatherEffect”Reference to the vanilla WeatherEffect object. Use TimeOfDay.Instance.effects[LevelWeatherType] wherever possible instead of accessing this directly.
Methods
Section titled “Methods”DisableEffect
Section titled “DisableEffect”Disables the weather effect.
Parameters:
permanent- Iftrue, setsEffectEnabledto false. Iffalse, only deactivates theEffectObject.
Creating an ImprovedWeatherEffect
Section titled “Creating an ImprovedWeatherEffect”In Unity Editor
Section titled “In Unity Editor”- Right-click in the Project window
- Select
Create > WeatherRegistry > ImprovedWeatherEffect - Configure the properties:
- Assign your effect GameObject to
EffectObject - Assign your world GameObject to
WorldObject(optional) - Set the
SunAnimatorBoolif needed - Configure default variables if required
- Assign your effect GameObject to
In Code
Section titled “In Code”Usage Examples
Section titled “Usage Examples”Basic Weather Effect
Section titled “Basic Weather Effect”Effect with Custom Variables
Section titled “Effect with Custom Variables”Enabling/Disabling Effects
Section titled “Enabling/Disabling Effects”Best Practices
Section titled “Best Practices”-
GameObject Management: Always instantiate your effect and world objects before passing them to
ImprovedWeatherEffect, and set them toDontDestroyOnLoad: -
Effect Objects vs World Objects:
- Use
EffectObjectfor client-side effects (particles, sounds) - Use
WorldObjectfor persistent world changes (water, fog volumes)
- Use
-
Null Checks: Both
EffectObjectandWorldObjectcan be null. The system handles this gracefully: