Creating independently usable mouse cursors during gameplay for local splitscreen multiplayer

Hi, I am creating a game with two player local splitscreen multiplayer component that requires both the players (Keyboard + Gamepad) or (Gamepad + Gamepad) to operate the mouse cursor independently.

The project is mostly done in C++. The game is a combination of a Third Person Shooter plus Top Down Puzzle with switchable camera orientation during gameplay. And I need the use of mouse cursor while using the Top Down camera orientation.

I searched for solutions and tried using GamepadUMGPlugin to create a virtual cursor and while that allowed me to operate mouse cursor with the gamepad, it did not allow two independently operatable cursors in a splitscreen.

This is an important gameplay requirement and any help in finding a way to achieve this will be greatly appreciated!!!

(My Engine Version is 4.22.3)

All you really need to do is be able to place the images you are using as a mouse cursor at specific screen coordinates. Two basic ways to do this are drawing directly to the canvas (via the HUD) or by using Slate/UMG widgets.

For the first option, look at AHUD, specifically DrawHud()

There’re a lot of ways to do this using Slate or UMG. You can create an individual SImage widget for each cursor and manually place them. Or you could create a container widget that updates the positions of any number of cursor images based on the screen coordinates you’d like to use.

Your container widget could be a UUserWidget that uses an SOverlay widget sized to fill the full screen, and then adjust margins/offsets of the children.

Look at UGameViewportClient, AddViewportWidgetContent and AddViewportWidgetForPlayer will be helpful.

Once you can place an image anywhere on the screen, you just need to update the image positions based on player input. You can get the position of the mouse on the screen with APlayerController::GetMousePosition, or use gamepad/keyboard/whatever input you choose.

You could also have one player’s cursor be the “real” mouse cursor and only create a “fake” cursor for additional players. Look at APlayerController::SetMouseCursorWidget and UGameViewportClient::AddCursorWidget SetHardwareCursor, SetVirtualCursor

Thanks a lot for your reply!!! Your suggestion seems like a real possibility.
Working on trying to make it happen. Will get back soon.

Hi, I managed to create fake UMG cursors for Gamepads for Both Players plus mouse cursor for Player One when using Keyboard by adding a widget component (with pointer image) to character blueprint and then controlling it with input axis mapping. Also, I spawned actors at widget location through player controller. That solved my gameplay requirement.

Thanks again to Gigasight Media for valuable suggestions.

Awesome!
Glad to help.