I
iambrettsoha
Guest
Hi all,
Experimenting with an unusual control scheme.
Player has two hands but only controls one at a time. They can alternate control with Right-click, while Left-click "grabs". If you switch control while grabbing, the hand retains its location.
These hands are controlled by the mouse movement, but in order to keep the hands locations independent from each other, I scrounged up some code to move the "active" hand by the relative mouse movement instead of just having it be 1 to 1 with the mouse coordinates. (sorry about that run-on sentence)
As far as I can tell, my code "works." But in order for it to pull together I need to be able to track the mouse's relative movement, even when outside of the game window.
Clamping the Mouse coordinates won't allow proper hand movement, and get_mouse_x() was also restrained to the game window's dimensions.
Here's a gif for some visuals
Here is the relevant code:
Step Event:
if (global.hand == "L")
{
if (grab = false || mouse_check_button(mb_left))
{
var diffx = mouse_x - premouse_x; //an artificial origin point is created each time the player switches hands
var diffy = mouse_y - premouse_y;
var x_ = pre_x + diffx; //the previous position of the hand is also stored in pre_x /pre_y whenever player switches
var y_ = pre_y + diffy;
x = lerp(x,x_,.3);
y = lerp(y,y_,.3);
}
}
else
{
x = x; //hand remains static when not selected, or when "grabbing"
y = y;
}
I appreciate any/all tips or suggestions
Experimenting with an unusual control scheme.
Player has two hands but only controls one at a time. They can alternate control with Right-click, while Left-click "grabs". If you switch control while grabbing, the hand retains its location.
These hands are controlled by the mouse movement, but in order to keep the hands locations independent from each other, I scrounged up some code to move the "active" hand by the relative mouse movement instead of just having it be 1 to 1 with the mouse coordinates. (sorry about that run-on sentence)
As far as I can tell, my code "works." But in order for it to pull together I need to be able to track the mouse's relative movement, even when outside of the game window.
Clamping the Mouse coordinates won't allow proper hand movement, and get_mouse_x() was also restrained to the game window's dimensions.
Here's a gif for some visuals
Here is the relevant code:
Step Event:
if (global.hand == "L")
{
if (grab = false || mouse_check_button(mb_left))
{
var diffx = mouse_x - premouse_x; //an artificial origin point is created each time the player switches hands
var diffy = mouse_y - premouse_y;
var x_ = pre_x + diffx; //the previous position of the hand is also stored in pre_x /pre_y whenever player switches
var y_ = pre_y + diffy;
x = lerp(x,x_,.3);
y = lerp(y,y_,.3);
}
}
else
{
x = x; //hand remains static when not selected, or when "grabbing"
y = y;
}
I appreciate any/all tips or suggestions