Download

bShowMouseCursor not working as expected?

Hey everyone!

So, I’ve been working on adding controller support to my game, and I created a variable (bIsUsingGamepad) that tells me when the player is using a gamepad. (Based on this article)

Based on that variable, I’d like to toggle both the mouse cursor and the mouse decal component (CursorToWorld), this is how I’m doing it at the moment.




            if (ADGProjectPlayerController* PlayerController = Cast<ADGProjectPlayerController>(GetController()))
            {
                if (!PlayerController->bIsUsingGamepad)
                {
                    CursorToWorld->SetVisibility(true);
                    PlayerController->bShowMouseCursor = true;
                    CursorToWorld->SetWorldLocation(TraceHitResult.Location);
                    CursorToWorld->SetWorldRotation(CursorRotation);
                }
                else
                {
                    CursorToWorld->SetVisibility(false);
                    PlayerController->bShowMouseCursor = false;                            
                }

                if(PlayerController->bShowMouseCursor)
                    UE_LOG(LogTemp, Warning, TEXT("True"))
                else
                    UE_LOG(LogTemp, Warning, TEXT("False"))

            }   



That’s all of course inside the tick function on my character class.

It sort of works sometimes, but not all the time. Sometimes the log outputs False but the cursor is visible, like for example in this picture, the log is outputing false, the cursor should be off but it isn’t. If I move the mouse it will dissappear, but if I just leave it there the cursor will stay, how can I make it so it dissappears instantly?

Am I missing something here? I’d greatly appreciate any ideas/tips, thanks!