Does blueprint code support compile-time constants?

Does blueprint code support compile-time constants (aka defines from C++)?
Does the compiler remove dead Blueprint code from built executable?

Judging from experience it does seem like they don’t compile nodes that are not connected, here they also give an overview of blueprint compilation, in it there is a sentence:

Prunes any nodes that are unscheduled or not a data dependency.

Although I am not sure it may mean that they do remove dead code.


What I have done though in place of compile time constants is used macros.

  1. First create a macro and name it something appropriate, eg. MY_CUSTOM_FLOAT_CONSTANT
  2. Then for organizational purposes I change its category to Constants so that all constants will neatly be grouped together.
  3. Open the macro and in the output add a single output of the type you want and name it something like Val.
  4. Then just use this macro wherever you need to use the constant.

Now when you compile the macro should be expanded automatically plugging its value into whatever you have it connected to.

1 Like

I know this is almost a year old, but this was a really good resource. As a C++ developer trying to work with blueprints, this really helped.