Problem when moving vector using Tick and input events

Hello,
I’m trying to move a vector only when I move my camera (so it moves with the camera) and when I perform an in-game action at the same time, the vector points where I’m aiming right now.

APRT_Character::APRT_Character() { 
   VectorToMove = GetAimLocation(); 
}

My tick event keeps track of what was the vector’s value for the previous frame:

void APRT_Character::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	
	VectorValLastFrame = VectorToMove;
}

I try to move it whenever the AddControllerPitchInput or the AddControllerYawInput event is called with its parameter is != 0 (that means I’m adding input and moving the camera), and if I’m performing the action:

void APRT_Character::AddControllerPitchInput(float Val)
{
	Super::AddControllerPitchInput(Val);
    if(Val != 0.0f && bPerformingAction){
       MoveVector();
    }
}

void APRT_Character::AddControllerYawInput(float Val)
{
	Super::AddControllerYawInput(Val);
    if(Val != 0.0f && bPerformingAction){
       MoveVector();
    }
}

I calculate how much I have to move it by getting its position last frame and subtracting it from the position this frame, then adding:

void APRT_Character::MoveVector()
{
	VectorToMove += GetAimLocation() - VectorValLastFrame ;
}

That works fine, however, if I move the mouse slowly, it doesn’t work, I need to move it fast.
Also I have noticed that the more I limit the framerate (the lower it becomes) the less the problem happens (I need to move the mouse even more slow to make it happen), it seems like it’s an issue regarding the difference between the current and the previous frame.

The function order is correct, the inputs come first then they call the MoveVector() and only then the actors ticks, meaning the LastFrameValue is really the value from the last frame for those functions.

I have setup a debug line that traces from my character to VectorToMove to show the problem (the game is running @ 120fps): h - YouTube

Any ideas? Thanks!

Hello! You can do all stuff in Tick method and that may resolve this.

Hello, thx for your answer. How can I verify if I’m moving the mouse or not inside the tick event? I used the input events because that’s the way I found to verify this (val != 0). But I’m not sure how to do it inside tick

managed to migrate it to Tick, I checked the mouse location to see if it changes to determine if it’s moving or not, but still the problem is happening, any other ideas?

Hello again! Why dont just use this method FTransform::TransformVector | Unreal Engine Documentation with your Pawn Transform?