Making Function Library for Blueprint

Hello.
I don’t know a thing about C++, but I have to make my own function library because there is no node in blueprint to use bLockTranslation, bLockRotation, and CustomDOFPlaneNormal (using UE4.25) at runtime.
So far I’ve been able to make the node itself, but non functionnal, since I have absolutely no idea of how and what I’m supposed to do for making it work.
Again, I don’t know a thing about C++.
I read on a topic that I should write something like this:
FBodyInstance* pBodyInstance = meshComponent->GetBodyInstance();
pBodyInstance->CustomDOFPlaneNormal = FVector(1.0f, 0.0f, 0.0f);

My BP node looks like this:
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = “Physics”)
static FString MyLockAxis(FVector PlanNormal, bool LockTranslation, bool LockRotation);

As you can guess, I would like to set the bLockTranslation, bLockRotation, and CustomDOFPlaneNormal of the physics body, based on the inputs from the node.

Please help?

I made something similar some time ago, look here.

It’s a C++ actor component that you can add to any other scene component in your actors, and lock any axes of that component after.

There’s Readme file that explains how to install it.

There’s also a plugin that does the same, which doesn’t require c++ at all, but – DISCLAIMER – it doesn’t work as reliably as the component. IDK why. Plus is was created in 4.27, so you probably won’t be able to use it anyway.

In any case, you can look at the code inside, if you want to implement it yourself.

1 Like

Thanks, I was already studying it to get a better understanding, and although it is not too hard to understand, I still lack knowledge to get it fully. But I’m not giving up, and hopefully will get some help to achieve my little library function.
Btw, thanks for your contribution to make EU more accessible, it’s always nice to get a useful plugin, especially for non-coders like me :wink:

1 Like

I think I’m getting closer, but I’m still struggling a bit. How am I supposed to define the meshComponent variable? (in my project the mesh component is also root component, if that can help). Here is a pic of the code so far. Please don’t hesitate to point at errors. Thx.

How am I supposed to define the meshComponent variable?

Add it to the function parameters, maybe?

static void MyLockAxis(UPrimitiveComponent* meshComponent, FVector PlanNormal, bool LockTranslation, bool LockRotation);

And don’t forget to check if meshComponent is valid before calling its functions.

1 Like

Nice suggestion, thx. My node is still non fonctionnal, but i’m not done testing and verifying.

It’s working fine. Thanks @Tuerer for the very useful help.

Screens of it, in case anyone like me (non-coder) ever struggle with it.
For remider, it’s a Function Library in C++ for BluePrint use, to lock rotation and translation of a component on a custom plane. I call this node, then I call the “set constraint mode” node (I don’t know if it works the other way).

.h :

.ccp :

BP node :
LockNODE

1 Like