How to use GetConstrainedComponents()?

void UPhysicsConstraintComponent::GetConstrainedComponents(UPrimitiveComponent *&OutComponent1, FName &OutBoneName1, UPrimitiveComponent *&OutComponent2, FName &OutBoneName2)

Can someone help me learn how to call this function? The documentation leaves a bit to be desired and I’m not finding much thru googling. I’m relatively new to C++ but I know it’s asking for me to pass in variables so the function can modify them to give me the results but I don’t know how to create the variables to pass in.

I don’t need the bones if that helps. I’m just trying to get the two components connected to this PhysicsConstraint.

Thank You!

A function can have only one return type (void in this case), but sometimes you need to receive several values from a function. That’s where so-called out parameters come in handy.

Such out parameters are marked with & and DO NOT have const before the parameter type, and more often than not the name starts with Out, although it’s not required.

Using out parameters is easy; you just have to declare the variables before calling the function and pass them as parameters.

UPrimitiveComponent* Component1;
UPrimitiveComponent* Component2;
FName BoneName1;
FName BoneName2;
MyPhysicsConstraintComponent->GetConstrainedComponents(Component1, BoneName1, Component2, BoneName2);

And the values of your variables will be set by the function. Then you can use them as you want.

(If a parameter is marked with const and &, it just means that it will be passed by reference, not by copy. It’s not related to the issue, just for the info.)

Thanks Tuerer. Unfortunately, I’m still getting errors.

error C4840: non-portable use of class 'FString' as an argument to a variadic function
note: 'FString::FString' is non-trivial
note: see declaration of 'FString::FString'
note: the constructor and destructor will not be called; a bitwise copy of the class will be passed as the argument
note: see declaration of 'FString'```

Why do you need strings?

Can you show the code, not just an error?

Sorry that last error was from a ULog on the next line.