Blueprints currently only support the Set Constrained Components to set the actors ( as primitive component reference ) that are connected to the constraint. But I can not access these actors in the blueprint with a node like Get Constrained Components because it doesn’t seem to exist.
The current workflow would be to add two variables for the actors to the blueprint of the constraint and set them to editable. Then select the actors in the Details panel. And this looks like this:
(D’oh! I flipped the actors! An other reason why we need this… )
Very redundant or not ? :rolleyes:
So… please add a Get Constrained Components node.
Then it is a lot easier to access these actors to e.g. calculate the angle between them etc…
A workaround for this issue in 4.15 ( in 4.14 I got an warning that I try to connect two null actors… ) is to use the Set Constrained Components in the blueprint and just leave the Constraint Actor 1 and Constraint Actor 2 empty.
However I need to use the Set Constrained Components twice!
In the Construction Script: To see the gizmos of the constraint that connect the two constrained actors.
On Begin Play: To actually get the constraint to work.
Thing number three is that the Editor UI ( Constraint Actor 1 and Constraint Actor 2 ) of the Details panel is not updated at all and always displays None. I believe it should display the Constraint Actor 1 & 2 names after they were set in the Construction Script…
For everyone who is looking for this feature as blueprint node:
Create a New C++ Class -> Blueprint Function Library named ServoSupport
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;
}
This is for anyone that is not too familiar with C++ (like myself). After some head scratching, I realized that in order to get this code to compile you have to remove the ‘ROBOTICS_API’ in the header.
so instead of class ROBOTICS_API UServoSupport : public UBlueprintFunctionLibrary
it should read class UServoSupport : public UBlueprintFunctionLibrary