Using script referencing rather than events and delegates
Initially, I only knew about using events and delegates to call a function from another script. I used it in all my earlier projects and this one as well. But I still don't quite understand how it works. Then I came across the other approach; Referencing a script and calling its functions are a much simpler and easier way. As I've learned from ChatGPT, it is much easier to use events and delegates IF I'm using an event to call multiple functions on multiple scripts and objects. But in the way my code structure works, I always have a centralized script to handle one thing anyway. Therefore, I find it easier to use the referencing method. Here's an example of referencing:
BaseController.cs
-----------------
public void BaseBreach()
{
audioSource.clip = baseBreach;
audioSource.Play();
}
Pathfinder.cs
-------------
BaseController baseController = GameObject.Find("Base").GetComponent<BaseController>();
baseController.BaseBreach();
It's that easy.