Attempting to create a joint between objects that are both static. No joint created


I’ve been trying to create a ladder for my 2D game and I need my ladder links connect to eachother with joints. However, I’ve been unsuccessful when it comes to connecting two paperspritecomponents to eachother in c++. It works in UE4 editor - firstly I tried the approach with statichmeshcomponents, then with paperspritecomponents and it worked when done through editor.

Now when I tried to do the same thing via c++ it keeps throwing me the following error:

"Attempting to create a joint between objects that are both static. No joint created."

I logged everything out and it shows that both components have mobility 2 ([check mobility types here][1]) set up.
Here’s the picture of my log:


LadderAnchor isn't simulating physics as it's the anchorpoint, the components names are also correct.

I am not sure why are my papersprite not moving and the error keeps showing up.

NOTE: constraintcomponent is positioned 300 pixels to right of the anchorpoint, so the swing motion would take action if it starts working.

Waiting for your response.

With regards.

When I attempt to connect two components with eachother that have created defaultsubobjects in c++ previously, it is possible.

When I try to connect component that has created defaultsubobject and component that is created at runtime using NewObject(this, TEXT(“AnchorLink”)) factory pattern, it doesn’t work.

I had a similar problem, but I created both components in a constructor and, despite the warning, the constraint worked all the same.

But I noticed that I don’t get the warning if I use the SetConstrainedComponents function in the BeginPlay() of the actor. (Not PostInitProperties(), for example, it appears that there has to be some kind of initialization on the component before it’s seen as “dynamic” by the constraint… I’m guessing it has to do with how the physics engine works.)

So, when you create your component at runtime, it’s probably a good idea to wait for its’ BeginPlay() to kick in, before you call SetConstrainedComponents().

Also, I think you need to register your component with RegisterComponent() and attach it to another component with AttachToComponent() right after you create it with NewObject(), if you’re not already doing that.

I am currently having the same issue in unreal engine 5. I tried to make the physics constraint with “NewObject<…” and with “CreateDefaultSubobject<…” inside constructor, beginplay, and outside both. None of thoes things have worked for me. I also made sure that beginplay was already called when i call “SetConstraintComponents”. Also i checked that the components are movable.
I’d be glad for any advice.


Declare this way:
constrain->ComponentName1.ComponentName = link_base->GetFName();
constrain->ComponentName2.ComponentName = link_react->GetFName();

It works for me.

Where constrain is UPhysicsConstraintComponent* and link_base/link_react are UStaticMeshComponent*

I think SetConstrainedComponents were meant to be called after physic asset initialization or something like that.