Constraint Component invalid on BP to C++ Function

When I spawn a Physics Constraint Component in BP and initialize all the values and then pass it to a C++ target as a parameter, the Actor-Variables get set to NULL (but are C+±Class instances). Furthermore the constraint doesn’t react to any action called from the C++ variable pointer.

Is this a bug, or is there a proper way to spawn something in BP and save a pointer to it in C++ to work with it there?

Hey Omamanfred-

I tried to test this by creating an actor class and writing a function to print the name of a physics constraint component:

void  AMyActor::ConstraintTest(UPhysicsConstraintComponent* TestConstraint)
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 4.f, FColor::Magenta, TestConstraint->GetName());
	}
}

I created a blueprint based on this class and added a physics constraint component to it. I then printed out the name of the component both with a BP Print node and the ConstraintTest() function.

In doing so I saw the name printed both with the blueprint print as well as through code. Is this similar to how you’re passing the component into code?

Cheers

Doug Wilson

Hey, they way I’m doing it was like this:

I have a C++ Class with an pointer to an UConstraintComponent (empty at first). Then I go to a blueprint not related to this class and call AddConstraintComponent and call a C++ from there to set this new spawned Component to the pointer of the C++ Class. Before that I completely initialize the constraintedObjects, so they are set in the BP version. Now, when I give the pointer of the Component to the C++ class, both Constrained Actor 1 and Constrained Actor 2 are null-pointers, however the original constraint does work ingame. As expected, calling “BreakConstraint” in C++ doesn’t do anything whereas calling it from the BP actually does break it.
However, the pointer of the component itself seems to be valid.

As an Info: I check “Manual Attachment” on the Component

Hey OmaManfred-

Could you post some example code or blueprint screenshots so I can get an idea of what your setup looks like? What class is the class containing your UConstraintComponent a child of? If the blueprint is not related to the class with the pointer, how is the result of the add component referencing the class to set the pointer? How are you initializing the constraint?

Hi OmaManfred,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.