Using Fmath for creating custom node

I have 2 very stupid qiestions. I need create custom node from this function - FMath::ClosestPointOnTriangleToPoint | Unreal Engine Documentation
I create custom C++ class in ue4, but I’ve never written code. Im working only with animations, and no have time for learn to code.

  1. Who can write me a example of code for this function? (i need a simple math function in blueprint for compute closest point on triangle fron point in world space.)
  2. Why so many function in Fmath library not include in blueprints? This library have a many very useful functions. But I can not reach them :frowning:

Hi maslenok,

This actually isn’t too difficult to do. In the header file for your new code class, you would need to add a new function declaration that matches the one in the function you are wanting to call in a public section of your class. You also need to make sure it is a UFUNCTION with the BlueprintPure (or BlueprintCallable, if you want it to have execution pins) specifier. So something like this:

UFUNCTION(BlueprintPure, Category = TestCat)
FVector GetClosestPointOnTriangle(const FVector& Point, const FVector& A, const FVector& B, const FVector& C);

Then your definition for your function would simply call the function you want to call and return whatever that function returns. Something like this:

FVector AMyActor::GetClosestPointOnTriangle(const FVector& Point, const FVector& A, const FVector& B, const FVector& C)
{
	return FMath::ClosestPointOnTriangleToPoint(Point, A, B, C);
}

That will result in the following node for your Blueprint:

122676-node.png

Keep in mind that this node will only be available in Blueprints that are derived from your code class.

Wow, thanks so much! I hope I was able to create a lot of other functions without going into programming :slight_smile: