Updated: Apr 29
As the time for content implementation in my FMP approached, I was beginning to get worried about how I could effectively and easily implement quest logic as I knew I would need very specific things to trigger after certain events, which does not lend itself well to efficient coding practise. My past projects had been small enough that hard-coding events in duplicate or superfluous scripts but this time I knew that wasn't an option and that I would need to research for a solution.
Unity, as it so often does, happened to have the perfect in-built solution, Unity Events. These magnificent things allow you to call a Unity Event at a point in script, this Event can be made public and exposed to the inspector.
The event element in the inspector is then essentially a list of actions for the Event to perform when it is called. You can drag in scripts and call public functions; you can call specific function on components like Play() and Stop() on audio sources and you can activate and deactivate objects and their components. This was the perfect solution to my problem.
These events meant that I could have designated moments in gameplay where I could do anything I needed without needing to hard-code it. Needless to say, I have decided to use them everywhere. I have events for when a note is read, as can be seen to the left, I have events on the combat zones for when all enemies in the zone are dead or when the zone is reset on a player respawn. I have also made an object that simply has a trigger collider that calls events on trigger enter and on trigger exit that I have used to trigger actions like weather and sky changes.
Discovering Unity Events has certainly saved me an insane amount of time in the long run even If I had to back-track through scripts to set them up.