offalynne / Input

Comprehensive cross-platform input for GameMaker
https://offalynne.github.io/Input
MIT License
255 stars 33 forks source link

Trying to mimic Mouse as an analog stick #872

Closed mbeytekin closed 4 months ago

mbeytekin commented 4 months ago

I am adjusting the aim with the right analog stick in my game.

aim_up: input_binding_gamepad_axis(gp_axisrv, true), aim_down: input_binding_gamepad_axis(gp_axisrv, false), aim_left: input_binding_gamepad_axis(gp_axisrh, true), aim_right: input_binding_gamepad_axis(gp_axisrh, false),

What I want to do is to give the same feeling with mouse and keyboard control. I am hiding the mouse cursor to avoid confusion during gameplay. However, it feels like there is a virtual mouse cursor during the game because as the mouse moves away from the player, input_cursor_x and input_cursor_y also move away, so it doesn't always feel like it is working with the same sensitivity. To solve this, I tried a code like this:

var _cdist = point_distance(x, y, display_mouse_get_x(), display_mouse_get_y());

input_cursor_limit_circle(x, y, 20 + _cdist / 100, player); input_cursor_speed_set(20 + 1 / _cdist * 5, 0);

It actually worked partially. My goal is to change the limit and speed according to the player's x and y coordinates with the mouse. However, I couldn't fully achieve this. Is there an easy way to do this? Can I provide an aim with the same sensitivity regardless of how far the mouse moves?

offalynne commented 4 months ago

Download the project which includes examples for the player cursor as you describe.