Cook Error from references to optional objects

Hello, I am a virtual streamer using UE 5.1 to build an interactive set for my streams. I recently changed from using the default game mode and player options to custom ones so that I could set the player to be a character pawn containing a camera that streams with a Spout2 output, allowing me to control the camera position and angle while the program is running. The camera is the OWL Cinecam Capture from the Off World Live Livestreaming Toolkit.

Everything works perfectly in the editor, but when I went to package it, it fails at the cook stage with this error message;

UATHelper: Packaging (Windows): LogWindows: Error: Can’t save D:/StreamSetup/Saved/Cooked/Windows/StreamSetup/Content/Blueprints/StreamGameMode.uasset: Non-optional object (/Game/Blueprints/StreamGameMode.Default__StreamGameMode_C) has a reference to optional object (/Game/PlayerCharacterBP.PlayerCharacterBP_C:OWLCapture_GEN_VARIABLE.MaterialInstanceDynamic_0.MaterialInstanceDynamic_0EditorOnlyData). Only optional objects can refer to other optional objects.

I can’t find the Material Instance causing the problem, and I’ve looked all over but I can’t find any helpful information on how or if I should change it from optional to non optional. Closest I found was this forum post Optional Object Package/Cook Error

I’m pretty new to Unreal, and currently unsure where or how to look for the problem, let alone solve it, and would really appreciate any insight. Thank you!

Hello! I was having this same problem. I was able to resolve my issue by removing a line from my c++ code that included a UMaterialInterface*. Are you using blueprints exclusively?