Download

Physics / Blueprints: Get Constrained Components

Hey,

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:

b1716bdd459e34e581639547fe210654a11222d0.png
(D’oh! I flipped the actors! An other reason why we need this… :wink: )

Very redundant or not ? :rolleyes:

So… please add a Get Constrained Components node. :slight_smile:
Then it is a lot easier to access these actors to e.g. calculate the angle between them etc…

Best
Greetings

Still redundant…

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! :frowning:

  1. In the Construction Script: To see the gizmos of the constraint that connect the two constrained actors.
  2. 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

Is this buggy ?

A Get Constrained Components node still doesn’t exist ?

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…

2 Likes

This is amazing! Thank you!

I couldn’t get that C++ function to work, it kept returning “none”.

I made a workaround by creating 2 variables in the physics_constraint_component blueprint named “bound object 1” and “bound object 2”

Then when I create this constraint, I set those 2 variables.

Then any time you want, you can get the value of those variables.

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