159. Moving Values

void AShooterCharacter::MoveRight(float AxisValue)
{
	AddMovementInput(GetActorRightVector() * AxisValue);
}

void AShooterCharacter::LookUpRate(float AxisValue)
{
	AddControllerPitchInput(AxisValue * RotationRate * GetWorld()->GetDeltaSeconds());
}

In these two codes, the code on the top didn’t multiply delta time, the code on the bottom multiplied delta time. I wonder why. Why one multiplies delta time, and the other doesn’t.

PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis(TEXT("LookUpRate"), this, &AShooterCharacter::LookUpRate);

void AShooterCharacter::LookUpRate(float AxisValue)
{
	AddControllerPitchInput(AxisValue * RotationRate * GetWorld()->GetDeltaSeconds());
}

And I don’t know why I need LookUpRate in this code. Aren’t they both rotating? Why do I need both?

You need both if using the legacy input system otherwise Enhanced Input should take care of this issue.
The issue is that mouse input and input from an analogue stick is different.

With a mouse input the value the function is getting will be a delta from the previous position it was in last frame; making it already frame rate independent. An analogue stick on the other hand would just be giving out a value between -1 and 1 which would be a percentage; if you push halfway on the stick you’ll get a value of 0.5. This makes it frame rate dependent.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms