Component Sweep in Blueprint?

Hi AnswerHub,

I found a function I’d really like to use in a Blueprint, ComponentSweepMulti, but it’s a C++ function. Is there a way to expose this function in Blueprints? It would be a nice feature to have since not all sweep problems can be solved easily with lines, spheres, or capsules.

Thanks in advance!

It’s simple to expose a C++ function to blueprint. Simply write a declaration of UFunction before your function:

Just like:

// In header
UFUNCTION(...) // NO semicolon
YourFunction(...);

// In cpp file
YourClass::YourFunction(...){
  ... // implementation
}

If you need to expose an existing pure c++ function to bp, create a BP function library and add a new function which simply calls your desired function.

The macro UFUNCTION will be ignored by pure C++ compiler, but it shows that the function should be included in UE4 reflection system, and the UE4 Building Tool will add extra code with it for reflection and BP. To expose it to BP, add “BlueprintCallable” or “BlueprintPure”. For more arguments in the UFUNCTION macro, see “function specifier” in the documentation.

Please note that “BlueprintPure” functions in BP don’t have Exec pins. In these functions only the return results should matter and there shouldn’t be any action to input objects.