mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Joystick sensitivity for player movement (#11262)
This commit deprecates the forward, backward, left, and right binary inputs currently used for player movement in the PlayerControl struct. In their place, it adds the movement_speed and movement_direction values, which represents the player movement is a polar coordinate system. movement_speed is a scalar from 0.0 to 1.0. movement_direction is an angle from 0 to +-Pi: FWD 0 _ LFT / \ RGT -Pi/2 | | +Pi/2 \_/ +-Pi BCK Boolean movement bits will still be set for server telegrams and Lua script invocations to provide full backward compatibility. When generating these values from an analog input, a direction is considered active when it is 22.5 degrees away from either orthogonal axis. Co-authored-by: Markus Koch <markus@notsyncing.net> Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
parent
149d8fc8d6
commit
1d69a23ba4
10 changed files with 137 additions and 98 deletions
25
src/player.h
25
src/player.h
|
@ -49,10 +49,6 @@ struct PlayerControl
|
|||
PlayerControl() = default;
|
||||
|
||||
PlayerControl(
|
||||
bool a_up,
|
||||
bool a_down,
|
||||
bool a_left,
|
||||
bool a_right,
|
||||
bool a_jump,
|
||||
bool a_aux1,
|
||||
bool a_sneak,
|
||||
|
@ -61,14 +57,10 @@ struct PlayerControl
|
|||
bool a_place,
|
||||
float a_pitch,
|
||||
float a_yaw,
|
||||
float a_sidew_move_joystick_axis,
|
||||
float a_forw_move_joystick_axis
|
||||
float a_movement_speed,
|
||||
float a_movement_direction
|
||||
)
|
||||
{
|
||||
up = a_up;
|
||||
down = a_down;
|
||||
left = a_left;
|
||||
right = a_right;
|
||||
jump = a_jump;
|
||||
aux1 = a_aux1;
|
||||
sneak = a_sneak;
|
||||
|
@ -77,13 +69,9 @@ struct PlayerControl
|
|||
place = a_place;
|
||||
pitch = a_pitch;
|
||||
yaw = a_yaw;
|
||||
sidew_move_joystick_axis = a_sidew_move_joystick_axis;
|
||||
forw_move_joystick_axis = a_forw_move_joystick_axis;
|
||||
movement_speed = a_movement_speed;
|
||||
movement_direction = a_movement_direction;
|
||||
}
|
||||
bool up = false;
|
||||
bool down = false;
|
||||
bool left = false;
|
||||
bool right = false;
|
||||
bool jump = false;
|
||||
bool aux1 = false;
|
||||
bool sneak = false;
|
||||
|
@ -92,8 +80,9 @@ struct PlayerControl
|
|||
bool place = false;
|
||||
float pitch = 0.0f;
|
||||
float yaw = 0.0f;
|
||||
float sidew_move_joystick_axis = 0.0f;
|
||||
float forw_move_joystick_axis = 0.0f;
|
||||
// Note: These two are NOT available on the server
|
||||
float movement_speed = 0.0f;
|
||||
float movement_direction = 0.0f;
|
||||
};
|
||||
|
||||
struct PlayerSettings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue