Multiple Virtual Cursors?

Hello! I’ve got a local multiplayer game and I’m trying to implement virtual cursors to have a character select screen akin to something like Smash Bros, where up to 4 players are able to control cursors on screen. However, this has been pretty tricky.

It appears as though Unreal doesn’t allow for multiple cursors – despite there being a concept of “Faux Slate Cursors” within the engine (Defined in SlateApplication.cpp, it’s a subclass of ICursor), users (FSlateApplication::RegisterNewUser), and IInputProcessors which appear to imply that you can have multiple “input processors” existing at once for different users.

However, it does not appear there’s a way to utilize any of this to create multiple virtual cursors for users to use to interact with. All IInputProcessors are all passed in the same cursor on tick.

The alternative is to hack it together in UMG, but therein lies another problem: I can’t seem to find a way to poll/hittest UMG widgets, which stops me from detecting if a UMG “cursor” is overlapping an interactable UMG widget.

The last option I’ve considered/prototyped was to copy UWidgetInteractionComponent, and create a component for managing a virtual cursor. I also created a new Slate button that passes along the VirtualUserIndex of the player who interacted with it. This has been the most successful so far, but it also feels pretty dirty.

tl;dr
Is there any built in way to do multiple cursors? It seems like there’s tools for it that just aren’t implemented. If not, does anyone have any resources on how to simulate cursors? (e.g. Hit testing for UMG or just other implementations)

Thanks!

Gonna resurrect this post to see if you or anyone else has come up with a solution or not, as I’m also looking. : ) K thnx.

For anyone who might stumble across this in the future:
I was in a similar boat for my project, and ended up forking this VirtualCursor plugin for multiplayer. You can find the forked version here.

It’s reallyyy buggy though. Most notably, when you run the game in editor and activate the virtual cursor, the blueprint editor window will glitch out and prevent you from double-clicking connectors and also make it difficult to resize comment boxes and grab certain things. It’ll fix itself next time you restart the editor.

There’s also a bug wherein sometimes players’ cursors aren’t ready to be initialized when the game starts (it doesn’t really do anything, it’s just a weird warning I keep getting.)

Likewise, you’ll still need a way of displaying the cursor. This plugin will only handle the “logic” of moving players’ cursors, but displaying that on the screen is up to you.

What I ended up doing for my project is creating a “Cursor Widget” class (inheriting from UUserWidget), and a subsystem which handles adding, removing, and updating the cursor widgets. You could probably do something very similar by just having the cursor widget have a reference to the PlayerController, and update its position every tick based on the PlayerController’s cursor.

The second hurdle I had to jump over was to design a pick-up and place system for widgets. I tried to model it off the “drag” system that UE4 has, but it was honestly way more work than it was worth.

And even after all that, I can’t figure out a way to get player 1’s mouse cursor to stay hidden…

If I were to do it all over again, I might consider just using the UWidgetInteractionComponent and faking all of the picking up and placing of UI stuff. Even Smash Bros used 3D cursors and 3D tokens for most of their games.

Unreal really does not like the idea of having multiple cursors…

Last note: If you do decide to use my VirtualCursor plugin fork and you want to get information as to which player clicked on a widget, you can override the widget’s OnMouseButtonDown function (or any other functions like that with Pointer Events) and get the user index from the Mouse Event.

1 Like