I’m getting the transform of the component.
This is the setup:
The actor sits at: (X=-60.000000,Y=40.000000,Z=20.000000)
In the actor I made has a cube at (X=0.000000,Y=0.000000,Z=420.000000), which the c++ has a reference to.
Header file:
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class TESTBUG_API AMyActor : public AActor
{
GENERATED_BODY()
public:
AMyActor();
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "mesh")
UStaticMeshComponent* comp;
virtual void BeginPlay() override;
virtual void Tick( float DeltaSeconds ) override;
};
cpp file:
#include "TestBug.h"
#include "MyActor.h"
AMyActor::AMyActor()
{
PrimaryActorTick.bCanEverTick = true;
}
void AMyActor::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("world transform=%s"), *comp->GetComponentTransform().ToString());
UE_LOG(LogTemp, Warning, TEXT("relative transform=%s"), *comp->GetRelativeTransform().ToString());
}
void AMyActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
When I run it without physics enabled on the cube, the output log shows:
LogTemp:Warning: world
transform=-60.000000,40.000000,440.000000|0.000000,0.000000,-0.000000|1.000000,1.000000,1.000000
LogTemp:Warning: relative
transform=0.000000,0.000000,420.000000|0.000000,0.000000,-0.000000|1.000000,1.000000,1.000000
When I run it with physics enabled on the cube it shows:
LogTemp:Warning: world transform=-60.000000,40.000000,440.000000|0.000000,0.000000,-0.000000|1.000000,1.000000,1.000000
LogTemp:Warning: relative transform=-60.000000,40.000000,440.000000|0.000000,0.000000,-0.000000|1.000000,1.000000,1.000000