GAMEBREAKING - instantieting materials inside npc_behavior_class ALWAYS throws COOKING ERROR

Hello,

UEFN is still technically in its infancy so there are many dependencies stripped from the standard UE editor and because of that, it will usually take more experimentation and work arounds to fix the subsequent issues. More of the issues are related to memory due to budget limitations and the source control not being completely reliant on unreal’s servers. Typically if an asset is too large/heavy in memory or becomes corrupted after you reopen the project, the log will tell you the asset ID so the line error in your screenshot is a similar situation.

Potential solutions, even if temporary:

  1. Try to use a different Class for Material Instantiation since material instantiation works in creative_device but not in npc_behavior_class, consider moving the material instantiation logic to a creative_device class. Then, reference or interact with this device from your npc_behavior_class.

  2. Instead of directly instantiating the material in npc_behavior_class, try creating a helper function or a separate utility class to handle material instantiation. This can isolate the problem making it easier to compare the errors from using the npc_behavior_class vs the creative_device.

  3. Check the npc_behavior_class documentation as the npc_behavior_class may not support dynamic material instantiation as another result of the “dumbed down” feature hierarchy.

It would also help to know your specs and if you are using custom materials or sharing instances across more than 1 UEFN device or asset, like if you were to create Child actors to inherit all functionality from an existing blueprint.

Try this in Verse to manually link/call on the material:
verse
ProxyDynamicMaterial := ProxyMaterialInstanceFromDevice.DynamicMaterial

Use Material Parameter Collections to allow to control material properties without directly instantiating materials.

  1. Create an MPC in the editor and add necessary parameters.
    2. Use Verse to update the MPC values at runtime.
    3. Link the material instance to the MPC in the material editor.

If not, then assign the dynamic material instance to the NPC in the editor instead of in the Verse script as this can avoid instantiation at runtime altogether.

Modify the class to instantiate the material later. For example, on spawn or first use, instead of during class definition.

          verse
 OnBegin<override>()<suspends>: void =
     DynamicMaterial := M_TestDynamicMaterial_material{}

Remove all parameters or layers and test with a basic material. This can help identify whether the complexity of the material contributes to the error. As you may know, Unreal doesn’t like large textures or caches.

If all else fails:
- Close UEFN.
- Navigate to Engine/DerivedDataCache
- Delete the cache files and relaunch the editor

Instead of assigning the material directly in the NPC behavior script, assign this functionality to a creative_device and trigger it via event handling.

Let me know if you need more help