How to use APlayerController::GetInputMouseDelta?

I see it on documentation but I am confused as to the syntax and how it can be applied, can I get some examples referring to syntax ?

The input parameters are passed by reference (&), also known as an out parameter.

What that means, is that any values passed to the function will be modified.

In short, you need to create 2 variables you can pass into the function, call the function with those 2 variables, and the function will modify those 2 variables values.

So something like:
float DeltaX = 0.f;
float DeltaY = 0.f;

GetInputMouseDelta(DeltaX, DeltaY);

Now DeltaX’s and DeltaY’s values have changed to whatever.

EDIT: Also, “Delta” is a keyword of sorts in Unreal Engine, and it refers to “since last frame”. DeltaTime is the time since last frame, so DeltaX and DeltaY will be the X and Y since last frame.

There’s a really good explanation on pointers and references on reddit. Comment by RoyAwesome.

1 Like

Okay I tried that , but it just gave me an error that it was undefined, I have it in an actor file and I added the player controller header file and everything, but that doesn’t work. For more clarification, I want to make a rotatable and then when I turn my camera I want the value of the camera to affect the rotation. This is what I tried to make work:

void AInteractBase::BeginPlay()

FTimeline FCurveTimeline;
	UCurveFloat* CurveFloat;

	FRotator StartLoc;
	FRotator EndLoc;
	float ZOffset;

float MouseY = 0.0f;
float MouseX = 0.0f;

GetInputMouseDelta(MouseX, MouseY);

	FOnTimelineFloat TimelineProgress;
	TimelineProgress.BindUFunction(this, FName("TimelineProgress"));

	FCurveTimeline.AddInterpFloat(CurveFloat, TimelineProgress);
	StartLoc = EndLoc = GetActorRotation();
	EndLoc.Yaw += MouseY;


void AInteractBase::TimelineProgress(float Value)
//value between distances
FRotator NewLocation = FMath::Lerp(StartLoc, EndLoc, Value);

But it does not compile and just throws an error that GetInputMouseDelta is undefined

But it does not compile and just throws an error that GetInputMouseDelta is undefined

GetInputMouseDelta is a function inside the PlayerController class. You need to call it from a PlayerController.

I am assuming that you are making an interactable object. In that case, do you have a reference to the Character interacting with the object? If you do, you can get the PlayerController from the Character and call GetMouseInputDelta from the PlayerController.

So something like:

ACharacter* Char; (You need to figure out how to get this yourself or share more of your code)
APlayerController* PC = Char->GetPlayerController();
PC->GetInputMouseDelta(MouseX, MouseY);

Remember to cast the PlayerController to your PlayerController class, if you have a custom one.

1 Like

Excuse my late replies, I spent my time trying to figure this out. But I did what you said, I referenced my character and casted the playercontroller, take a look:

class APlayerCharacter;
class UCurveFloat;

class Rotatable_API AInteractBase : public AActor

// Sets default values for this actor’s properties

// Called when the game starts or when spawned
virtual void BeginPlay() override;

// Called every frame
virtual void Tick(float DeltaTime) override;

void TimelineProgress(float Value);

FTimeline FCurveTimeline;

UPROPERTY(EditAnywhere,Category = "Movement")
UCurveFloat* CurveFloat;

	FRotator StartLoc;
	FRotator EndLoc;

APlayerCharacter* Person;
APlayerController* PC = Person->GetPlayerController();


I get error “error C2059: syntax error: ‘=’” and “error C2238: unexpected token(s) preceding ‘;’”. Can you show me what I have done wrong?