COZY Documentation
  • Welcome!
    • πŸ‘‹Hello!
    • πŸ—ΊοΈRoadmap
    • πŸ†˜Support & Community
    • πŸŽ“Changelog
  • Getting Started
    • πŸ”ŒInstallation
    • πŸ› οΈSetting Up Your Project
    • 🌐Creating a New Scene
    • πŸ“¦COZY Samples
  • How it works
    • βš™οΈThe System Perspective
    • ⏱️Meridiem Time
    • 🌈Gradients & Curves
    • βš–οΈWeighted Random Chance (WRC)
    • πŸ§‘β€πŸ«Weather Selection & Forecasting
    • The Weather Sphere
      • 🌌The Sky Dome
      • ☁️The Cloud Dome
        • COZY Desktop Clouds
        • COZY Mobile Clouds
        • Soft Clouds
        • Painted Skies
        • Ghibli Desktop & Mobile Clouds
        • Single Texture Clouds
        • Luxury Clouds
      • 🌫️The Fog Dome
    • Modules
      • 🌌Atmosphere Module
      • πŸ•‘Time Module
      • 🌦️Weather Module
      • πŸƒAmbience Module
      • 🌑️Climate Module
      • ⚑Events Module
      • 🎨Interactions Module
      • ☁️Buto Module
      • 🌎MicroSplat Module
      • 🌳The Vegetation Engine (TVE) Module
      • πŸͺžReflections Module
      • πŸŒ™Satellite Module
      • πŸ—ƒοΈSave & Load Module
      • πŸŒ„Transit Module
      • πŸ’¨Wind Module
      • πŸ•‘System Time Module
      • πŸ›Debug Module
      • ☁️Plume Module
      • πŸŒ‡Blocks Module
      • πŸŒ‘Eclipse Module
      • πŸ“†Habits Module
      • 🎼ReSound Module
      • πŸ”—Link Module
    • Profiles
      • Ambience Profile
      • Atmosphere Profile
      • Forecast Profile
      • Perennial Profile
      • Satellite Profile
      • Material Profile
      • Weather Profile
      • FX Profiles
        • Audio FX
        • Climate FX
        • Cloud FX
        • Event FX
        • Filter FX
        • Multi FX
        • Particle FX
        • Precipitation FX
        • Thunder FX
        • Visual FX
        • Wind FX
      • Climate Profile
    • Biomes
    • Settings
  • Extending COZY
    • Stopping Indoor FX
    • Developing the Render Queue
    • Utilities
  • Integrations
    • Crest Water 4 (URP Only)
    • Crest Water 5
    • Stylized Water 2
    • KWS Water System
    • Generic Shader Graph
    • The Vegetation Engine
    • MicroSplat
  • Appendix
    • Frequently Asked Questions (FAQs)
    • Improving Performance With COZY 3
Powered by GitBook
On this page
  • Overview
  • Key Features
  • Control Events by Time of Day
  • Control Events by Time Passing
  • Control Events Based on the Weather
  • Usage Examples
  • Turn a light on in the evening and off in the morning
  • Add events that play during a certain weather type
  • Link methods to events in C#
  • Link methods to Event FX in C#

Was this helpful?

  1. How it works
  2. Modules

Events Module

PreviousClimate ModuleNextInteractions Module

Last updated 4 months ago

Was this helpful?

Overview

Use the COZY system to directly impact your world in a quick manner. The lightweight Events Module will provide you with access to many simple hooks that you can use to link functions to various events that can happen in the COZY system.

For more advanced control. see the .

Compatibility Information

Compatible with all modules however:

  • Time of day events require the or .

  • Set the times that time of day events happen in the .

  • Will not sync with LINK automatically!

Key Features

Control Events by Time of Day

  • Run an event at dawn.

  • Run an event at morning.

  • Run an event at day.

  • Run an event at afternoon.

  • Run an event at evening.

  • Run an event at twilight.

  • Run an event at night.

Control Events by Time Passing

  • Run an event when an in-game minute passes.

  • Run an event when the hour changes.

  • Run an event when the day changes.

  • Run an event when the year changes.

Control Events Based on the Weather

  • Run an event when the weather changes.

  • Run events when a weather profile with a certain Event FX profile is playing.

Usage Examples

Turn a light on in the evening and off in the morning

This is incredibly simple within the Events Module! Simply create a point light in your scene and in the Events Module add two events. In the OnMorning section, add an event that disables the point light, and in the OnTwilight section add an event that enables it:

In this example, we use the OnMorning event instead of the OnDawn event because we want the light to stay on for a bit longer. Dawn will typically run right before the sun rises. Similarly, we use the OnTwilight event instead of the OnNight event because there will be a little bit of natural light left during twilight. These will combine to give your scene a very natural lighting system that keep your game well lit!

Add events that play during a certain weather type

Click the Add New Event FX Reference button

Once your Event FX Reference is set, you can assign your events using the OnStart and OnStop Unity Events

Link methods to events in C#

For basic events, follow this C# script example. You can replace onDawn with any other COZY event that you want to listen to

using UnityEngine;
using DistantLands.Cozy;

public class EventRunningExample : MonoBehaviour
{

    private void OnEnable()
    {
        CozyWeather.Events.onDawn += PlayOnDawn;
    }

    private void OnDisable()
    {
        CozyWeather.Events.onDawn -= PlayOnDawn;
    }

    public void PlayOnDawn()
    {

    }
}

Link methods to Event FX in C#

For events that play based on Event FX, you will need to follow this for your C# script

using UnityEngine;
using DistantLands.Cozy.Data; //Event FX Profiles are stored in this namespace

public class RunFunctionWhenWeatherTypeStartsOrStops : MonoBehaviour
{

    [Tooltip("Assign the weather FX that you want to draw events from here!")]
    public EventFX eventFX;

   void OnEnable()
    {

        eventFX.onCall += DoSomething;
        eventFX.onEnd += DoSomethingElse;

    }

void OnDisable()
    {

        eventFX.onCall -= DoSomething;
        eventFX.onEnd -= DoSomethingElse;

    }

    public void DoSomething()
    {

        //This function will run when weather profiles that have the eventFx FXProfile attatched to it begin playing.

    }

    public void DoSomethingElse()
    {

        //This function will run when weather profiles that have the eventFx FXProfile attatched to it stop playing.

    }
}

Now select your FX reference. This is an profile that is assigned to several weather profiles that all fit a certain type. By default, COZY ships with 3 Event FX types for rainy, snowy, and foggy weather but you can create your own Event FX Profiles using the right-click context menu.

Habits Module
Time Module
System Time Module
Transit Module
Event FX
⚑
Page cover image