Hi [mention removed],
I don’t think there is a built-in way to extract the delta transforms of the camera between frames. I have not found a way to do this in Blueprint, but you can achieve this in C++ without that much work. I’ll write out the solution that I found out that does the job if you don’t want a hacky solution.
Unreal Engine source code has a C++ class called UCameraModifier, which allows developers to make any modifications to the final transform of the camera. For the CameraShake system, Unreal uses the UCameraModifier_CameraShake class that inherits from UCameraModifier.
What you can do, is create a new UCameraModifier_CameraShakeModifier that overrides the ModifyCamera function. This function allows you to extract the delta between frames of the camera:
MyCameraModifier.h
`UCLASS()
class TPP_54_API UMyCameraModifier : public UCameraModifier_CameraShake
{
GENERATED_BODY()
public:
UMyCameraModifier(const FObjectInitializer& ObjectInitializer);
FVector OldLocation;
virtual bool ModifyCamera(float DeltaTime, FMinimalViewInfo& InOutPOV) override;
};`
MyCameraModifier.cpp
`UMyCameraModifier::UMyCameraModifier(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
bool UMyCameraModifier::ModifyCamera(float DeltaTime, FMinimalViewInfo& InOutPOV)
{
UE_LOG(LogTemp, Warning, TEXT(“PreLocation: %s”), *OldLocation.ToString())
//Delta OldLocation - InOutPov.Location(New frame location)
FVector DeltaLocation = OldLocation - InOutPOV.Location;
//Update the frame location
OldLocation = InOutPOV.Location;
UE_LOG(LogTemp, Warning, TEXT(“DeltaLocation: %s”), *OldLocation.ToString())
UE_LOG(LogTemp, Warning, TEXT(“PostLocation: %s”), *OldLocation.ToString())
return Super::ModifyCamera(DeltaTime, InOutPOV);
}`
This class inherits the default behaviour of the UCameraModifier_CameraShake, and also enables you to extract the delta of the camera. To use your Camera Modifier instead of the default one, you need to register it:
`void AMyPlayerController::BeginPlay()
{
Super::BeginPlay();
if (PlayerCameraManager)
{
// Find existing shake modifier
UCameraModifier_CameraShake* DefaultMod =
Cast<UCameraModifier_CameraShake>(
PlayerCameraManager->FindCameraModifierByClass(UCameraModifier_CameraShake::StaticClass())
);
if (DefaultMod)
{
PlayerCameraManager->RemoveCameraModifier(DefaultMod);
}
// Add yours
UMyCameraModifier* MyMod =
Cast(
PlayerCameraManager->AddNewCameraModifier(UMyCameraModifier::StaticClass()));
PlayerCameraManager->PostInitializeComponents();
if (MyMod)
{
MyMod->Priority = DefaultMod ? DefaultMod->Priority : 0;
}
}
}`
With these changes you can extract the real delta of the camera without a hacky solution or modifying the engine source code.
Let me know if this did the job.
Best,
Joan