Does the Mouse object exist regardless of device?

Hi, and thanks for reading in advance.

I’m making a little clone of Fat Princess - it’s a team-based CTF-styled class fighter that utilizes five playable roles to help rescue your princess from the enemy team’s stronghold.

One of those five is Priest, a class whose actions (and their required inputs) change contextually.

There are only two types of attacks in Fat Princess - normal and charged. For keyboard/mouse combination users, these are binded to left mouse and E, respectively; X and Y for gamepad users, and a simple tap or a press of an exclusive UI element for mobile users.

Priest alters this dynamic slightly by having a concentrated healing beam bound to the same input as his normal attack, a simple swipe of his staff. Currently, I determine whether or not to use the healing beam based on the mouse’s current Target property when the left mouse button is clicked. If your mouse is currently over a nearby ally, you’ll use the healing beam - and the staff swipe is used in all other cases. My issue arises when I consider other input formats. Do gamepads and mobile devices even use a cursor? Would this be optimal?

If they don’t or it’s not an optimal choice, maybe I should opt for a different system - perhaps something utilizing the camera. I’m definitely open to suggestions.

Thanks!

1 Like

It does, but you shouldn’t use the PlayerMouse for non-computer devices. In fact, you honestly shouldn’t use the Mouse object at all.

The substitute (or rather proper) option is to use ViewportPointToRay with the coordinates of input from an InputObject and a UserInputService event, then extend that ray’s length and perform a raycast. This will ensure consistency irrespective of platform because you’re following the same formula that respects the position of input a user gives to the game (finger location, mouse click, whatever).

You may have trouble with Xbox if you explicitly need position since thumbsticks are handled in terms of the delta movement of them rather than a specific position away from the center of the screen. I’m sure that’s a non-problem though.

Yeah, not sure what I’d do about gamepads. I’m sure having to center someone on your screen would be a hassle. Maybe I’ll give gamepads an exclusive lock-on feature.