Skip to content

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.

public GameObject EffectObject

The GameObject that is visible only to the player. This typically includes:

  • Rain particles
  • Sound effects
  • Screen effects
  • Other client-side visual elements
public GameObject 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
public string SunAnimatorBool { get; set; }

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
public int DefaultVariable1 { get; set; } = 0;
public int DefaultVariable2 { get; set; } = 0;

Default weather variables used by the game’s weather system. These correspond to the weatherVariable and weatherVariable2 fields in vanilla’s RandomWeatherWithVariables.

public virtual bool EffectEnabled { get; set; }

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
public bool EffectActive { get; }

Read-only property that returns whether the EffectObject is currently active.

public LevelWeatherType LevelWeatherType { get; internal set; }

The vanilla weather type enum value associated with this effect.

public WeatherEffect VanillaWeatherEffect { get; internal set; }

Reference to the vanilla WeatherEffect object. Use TimeOfDay.Instance.effects[LevelWeatherType] wherever possible instead of accessing this directly.

public virtual void DisableEffect(bool permanent = false)

Disables the weather effect.

Parameters:

  • permanent - If true, sets EffectEnabled to false. If false, only deactivates the EffectObject.
  1. Right-click in the Project window
  2. Select Create > WeatherRegistry > ImprovedWeatherEffect
  3. Configure the properties:
    • Assign your effect GameObject to EffectObject
    • Assign your world GameObject to WorldObject (optional)
    • Set the SunAnimatorBool if needed
    • Configure default variables if required
// Create from GameObjects
GameObject effectObject = /* your effect GameObject */;
GameObject worldObject = /* your world GameObject */;

ImprovedWeatherEffect effect = new(effectObject, worldObject)
{
    SunAnimatorBool = "overcast",
    DefaultVariable1 = 0,
    DefaultVariable2 = 0
};

// Create from vanilla WeatherEffect
WeatherEffect vanillaEffect = TimeOfDay.Instance.effects[(int)LevelWeatherType.Rainy];

ImprovedWeatherEffect improvedEffect = new(vanillaEffect);
// Create effect objects
GameObject rainParticles = /* your rain particle system */;
GameObject puddles = /* your puddle objects */;

// Create the improved weather effect
ImprovedWeatherEffect rainEffect = new(rainParticles, puddles)
{
    SunAnimatorBool = "overcast"
};

// Use in a Weather object
Weather customRain = new Weather("Custom Rain", rainEffect)
{
    Type = WeatherType.Modded,
    ColorGradient = ColorConverter.ToTMPColorGradient(Color.blue)
};
ImprovedWeatherEffect stormEffect = new(effectObj, worldObj)
{
    SunAnimatorBool = "overcast",
    DefaultVariable1 = 2,  // Storm intensity
    DefaultVariable2 = 5   // Lightning frequency
};
// Enable the weather effect
myEffect.EffectEnabled = true;

// Disable temporarily (keeps EffectEnabled = true)
myEffect.DisableEffect(permanent: false);

// Disable permanently
myEffect.DisableEffect(permanent: true);

// Check if effect is active
if (myEffect.EffectActive)
{
    // Effect is currently visible
}
  1. GameObject Management: Always instantiate your effect and world objects before passing them to ImprovedWeatherEffect, and set them to DontDestroyOnLoad:

    GameObject effectObject = GameObject.Instantiate(prefab);
    effectObject.hideFlags = HideFlags.HideAndDontSave;
    GameObject.DontDestroyOnLoad(effectObject);
  2. Effect Objects vs World Objects:

    • Use EffectObject for client-side effects (particles, sounds)
    • Use WorldObject for persistent world changes (water, fog volumes)
  3. Null Checks: Both EffectObject and WorldObject can be null. The system handles this gracefully:

    ImprovedWeatherEffect clearWeather = new(null, null);