Should I use plugins or plain objects inherited from UObject for a numerical solver?

Basically, I want to implement some numeral algorithms in the unreal engine, like finite differencing and RK4. I think I have several ways to do it. I can add a plugin and write my code there. Or I can just add a new c++ class inherited from UObject and include that class whenever I need it. Which way should I go, or is there any other recommended best practice for this task?

The easiest way I can think of is:

  1. Get the plugin template (Plugins | Unreal Engine 4.27 Documentation) from UE4 Editor for a Blueprint Function Library
    (last time I checked, 4.27 didn’t have all the usual plugin templates, so use prior version if necessary)

  2. Add your code there.

Now you have a plugin that contains statically accessible nodes to do the math logics you want, which means they can be called from anywhere, without instancing an object.

If you need persistent variable storage over time, so it can’t be just a single blueprint node, then yes, adding an object to handle all of your math logic is viable, I have a tutorial related to that here:

UObjects for fancy C++ Code

  1. I do recommend using a plugin even for your uobject class, which you can just add to your BP Library plugin somewheres. Reason: You could eventually add your plugin to the marketplace, and especially in UE5, plugins compile VERY fast, and even within Epic, many projects, I’ve observed, have tended to start using plugins for different aspects of a larger project.

So Plugins are very much the

:rainbow: :boom: :tulip: :sparkles: Hot Pink Sparkly Rainbow of Excitement :rainbow: :boom: :tulip: :sparkles:

These days, in the UE World…

(The only :zap: Real :zap: World)!

Enjoy!

:sparkling_heart:

Rama

2 Likes