Hello! I’m new to Unity and scripting in general so please bear with me if my question is absurd.
I’m playing around with a choose-your-own-adventure FMV game and, having built a successful test, I quickly realised that my whole framework was very messy, not modular, and would not be easy to expand going forward. I’ve deconstructed the entire thing and am trying to build it back up so that my scripts are simple and perform basic that follow an obvious flow.
I wanted everything to flow through an intermediate Game Manager so that I wouldn’t get needlessly entwined in which script is talking to which and so on. Here is an instance of what I have done:
- I have a script that reads my player choices (e.g. go left or go right) and a script that deals with my video player. Once the choice is made, I wanted my choice script to pass the selected choice to the video player.
- In my frame, the Choice Manager speaks to the Video Player through the Game Manager. So passing a choice would look something like:
gameManager.videoPlayer.PlayNextChoice(choice1)
My problem is: Because I’m not directly finding the video player with the choice manager and, instead, going through the game manager, I just get a NullReferenceException (Object reference not set). I’m assuming this is because the Game Manager has a public Choice Manager, which, even though I’ve used FindObjectOfType in Start, is overridden in the inspector by a value of nothing.
I’m a bit stuck with which direction to go next - I thought this would be a clear and simple way for me to connect everything but I’m obviously not going the right way about it. Is my whole system just senseless and, if so, are there any pointers you could give that might help point me in the right direction?
Thanks so much for your time, I really appreciate any thoughts.
- A