I am having some trouble getting Mouse Input working. I started with the Top Down Template and wanted to play around with camera movement a bit. First I added this to my PlayerController::SetupInputComponent:
void AMyProjectPlayerController::RotateCameraX(float Value)
{
}
void AMyProjectPlayerController::RotateCameraY(float Value)
{
AMyProjectCharacter* Player = Cast<AMyProjectCharacter>(GetPawn());
if (Player && Value != 0.0f)
{
USpringArmComponent *Arm = Player->CameraBoom;
FRotator Rot(0.0f, Value * GetWorld()->GetDeltaSeconds(), 0.0f);
Arm->AddRelativeRotation(Rot);
}
}
The third step was to add the input in the editor. So I did this and added a Axis Input. One with Mouse Y and one with Mouse X.
Now when I run the Game, and I set a breakpoint in the function RotateCameraY, i NEVER get a value for Value > 0.0f. Its always 0.0f. Doesn’t matter how fast I move the mouse. Is there anything blocking my input ?
Yes, the two methods get called repeatedly. But only with a Value of 0.0f. Thus if I set a breakpoint within the if statement, it will never get triggered.
This will make sure your mouse is setup as an axis and then your DoRotationY will be picked up correctly by your SetupInputComponent. Also, is this on a character class and is the SetupInputComponent being overridden in the header?
Hi Dune, the function works now. It had indeed to do with my Mapping AxisName. I had a typo there. There is now another issue: It doesn’t work if I don’t hold the left/right mousebutton. Unfortunately when I keep the left or right mouse button pressed, then the movement will get triggered.