Physics / Blueprints: Get Constrained Components

For everyone who is looking for this feature as blueprint node:

  1. Create a New C++ Class -> Blueprint Function Library named ServoSupport
  2. Copy & Paste the code:

Header file:



// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "PhysicsEngine/PhysicsConstraintComponent.h"
#include "ServoSupport.generated.h"


/**
 *
 */
UCLASS()
class ROBOTICS_API UServoSupport : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

        UFUNCTION(BlueprintPure, Category = "Servo")
        static void GetConstrainedActors( UPhysicsConstraintComponent* ServoComponent, AActor*& ConstraintActor1, AActor*& ConstraintActor2 );
};


CPP:



// Fill out your copyright notice in the Description page of Project Settings.


#include "ServoSupport.h"

void UServoSupport::GetConstrainedActors(UPhysicsConstraintComponent* ServoComponent, AActor*& ConstraintActor1, AActor*& ConstraintActor2)
{
    ConstraintActor1 = ServoComponent->ConstraintActor1;
    ConstraintActor2 = ServoComponent->ConstraintActor2;
}


Feel free to refactor the names… :wink:
Hope this helps! :slight_smile:

Maybe I’ll find the time to pull request this…

3 Likes