Hey, so I have a top down project that supports both controller and mouse.
Currently I convert controller stick input into a rotation and use the mouse location and convert that into rotation to aim my character:
// Create fire direction vector from controller input const float FireForwardValue = GetInputAxisValue(FireForwardBinding); const float FireRightValue = GetInputAxisValue(FireRightBinding); const FVector FireDirection = FVector(FireForwardValue, FireRightValue, 0.f); // MouseInput APlayerController* PC = GetWorld()->GetFirstPlayerController(); FHitResult MouseTrace; PC->GetHitResultUnderCursor(ECC_Visibility, true, MouseTrace); FVector CharToMouse; CharToMouse = MouseTrace.Location - this->GetActorLocation(); CharToMouse.Z = 0; if(FireDirection != FVector(0, 0, 0)) TargetTurretRot = FireDirection.Rotation() - RootComponent->GetRelativeRotation(); else //else if (GetMKInput()) //make timed out instead for per tick TargetTurretRot = CharToMouse.Rotation() - RootComponent->GetRelativeRotation();
However, this means that M&KB players can just point and click to aim, which is significantly easier than the controller having to aim from the center of the pawn based on rotation, and I wish to make each option balanced.
So I wish to get the mouse movement, and turn it into a rotation, movement in the left direction rotates towards 90 degrees, moving the mouse right turns it towards 180, moving the mouse back turns towards 135 and forwards towards 360/0. But I can’t even find an input variable for the mouse movement and don’t even know where to begin looking to accomplish this.
Edit: I suppose I could capture the mouse coordinates and compare to last frame, but wouldn’t that cause issues if the invisible cursor hits the edge of the frame?
Edit2: I was just having a mindfart, I was able to just go back to basics and set up mouse axis bindings without issues.