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.
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.)
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
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:
Keep in mind that this node will only be available in Blueprints that are derived from your code class.