Why does GetPendingMovementInputVector always return (0,0,0) in this context?

I’m building a soft target locking system which examines every target in range, weighs distance, facing, and a bunch of other stuff, and determines which target I’m trying to hit. Currently, I’m trying to add a weight for the direction of movement input, e.g. the enemy closest to the direction the player is holding the movement keys in.

The simplest way to do this seems to be to get the FVector of desired movement via GetPendingMovementInputVector:

			FVector normDirection = (targetList*->GetActorLocation() - myActor->GetActorLocation()); //Get the normalized direction between currently-analyzed enemy and the attacker
                        float controlWeight = FVector::DotProduct(myCharacter->GetPendingMovementInputVector(), normDirection); //Compare the player's movement vector to the direction to his target. This should produce a number within range 1, -1, where 1 means that the player is holding the movement keys to move directly toward this enemy

This always returns a value of 0, and after testing with some debug messages I’ve found that myCharacter->GetPendingMovementInputVector() always returns a value of FVector(0,0,0), even while holding multiple keys. The code for movement is taken directly out of the C++ example, and involves getting a direction and velocity, then running:

AddMovementInput(Direction, Value);

So I know movement is being applied, is there an obvious flaw here preventing me from getting that input back as a vector?

Edited to add: I still don’t know why it’s returning zero, but I did cobble a solution together: GetMovementInputVector and GetPendingInputVector both return 0s across the board, but GetLastInputVector works, and that’s all I need to achieve the desired behavior :slight_smile:

Hi HInoue,
if it still interesting for you or readers, try to use GetLastInputVector() instead.

It looks like the ControlInputVector you are trying to access is always cleared in UCharacterMovementComponent::TickComponent.