update feature #5 & #1

This commit is contained in:
AleaJactaEst 2022-03-06 22:28:43 +01:00
parent 2350c98af9
commit d26ec0da5c
9 changed files with 343 additions and 178 deletions

View file

@ -114,118 +114,115 @@ msgid "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
msgstr "Please select your button joypad" msgstr "Please select your button joypad"
msgid "INPUT_ACTION_UP" msgid "INPUT_ACTION_UP"
msgstr "" msgstr "Up"
msgid "INPUT_ACTION_DOWN" msgid "INPUT_ACTION_DOWN"
msgstr "" msgstr "Down"
msgid "INPUT_ACTION_LEFT" msgid "INPUT_ACTION_LEFT"
msgstr "" msgstr "Left"
msgid "INPUT_ACTION_RIGHT" msgid "INPUT_ACTION_RIGHT"
msgstr "" msgstr "Right"
msgid "INPUT_ACTION_STRAFE_LEFT" msgid "INPUT_ACTION_STRAFE_LEFT"
msgstr "" msgstr "Strafe Left"
msgid "INPUT_ACTION_STRAFE_RIGHT" msgid "INPUT_ACTION_STRAFE_RIGHT"
msgstr "" msgstr "Strafe Right"
msgid "INPUT_ACTION_RUN" msgid "INPUT_ACTION_RUN"
msgstr "" msgstr "Run"
msgid "INPUT_ACTION_AUTO_UP" msgid "INPUT_ACTION_AUTO_UP"
msgstr "" msgstr "Auto move"
msgid "INPUT_ACTION_SIT_DOWN" msgid "INPUT_ACTION_SIT_DOWN"
msgstr "" msgstr "Sit down"
msgid "INPUT_ACTION_FLY" msgid "INPUT_ACTION_FLY"
msgstr "" msgstr "Fly"
msgid "INPUT_ACTION_ENTER_VEHICLE" msgid "INPUT_ACTION_ENTER_VEHICLE"
msgstr "" msgstr "Enter in vehicle"
msgid "INPUT_VIEW_CAMERA_LEFT" msgid "INPUT_VIEW_CAMERA_LEFT"
msgstr "" msgstr "Camera Left"
msgid "INPUT_VIEW_CAMERA_RIGHT" msgid "INPUT_VIEW_CAMERA_RIGHT"
msgstr "" msgstr "Camera Right"
msgid "INPUT_VIEW_CAMERA_UP" msgid "INPUT_VIEW_CAMERA_UP"
msgstr "" msgstr "Camera Up"
msgid "INPUT_VIEW_CAMERA_DOWN" msgid "INPUT_VIEW_CAMERA_DOWN"
msgstr "" msgstr "Camera Down"
msgid "INPUT_VIEW_UP" msgid "INPUT_VIEW_UP"
msgstr "" msgstr "View Up"
msgid "INPUT_VIEW_DOWN" msgid "INPUT_VIEW_DOWN"
msgstr "" msgstr "View Down"
msgid "INPUT_VIEW_FRONT" msgid "INPUT_VIEW_FRONT"
msgstr "" msgstr "View front"
msgid "INPUT_VIEW_BACK" msgid "INPUT_VIEW_BACK"
msgstr "" msgstr "View back"
msgid "INPUT_VIEW_CAMERA_FPS_TPS" msgid "INPUT_VIEW_CAMERA_FPS_TPS"
msgstr "" msgstr "First person / Third person"
msgid "INPUT_VIEW_SCREENSHOT" msgid "INPUT_VIEW_SCREENSHOT"
msgstr "" msgstr "Screenshot"
msgid "INPUT_VIEW_ZOOM_IN" msgid "INPUT_VIEW_ZOOM_IN"
msgstr "" msgstr "Zoom in"
msgid "INPUT_VIEW_ZOOM_OUT" msgid "INPUT_VIEW_ZOOM_OUT"
msgstr "" msgstr "Zoom out"
msgid "CONTROL_VIEW_BY_GROUP" msgid "CONTROL_VIEW_BY_GROUP"
msgstr "" msgstr "By Group"
#, fuzzy
msgid "CONTROL_VIEW_BY_INPUT" msgid "CONTROL_VIEW_BY_INPUT"
msgstr "Sort by input" msgstr "by input"
msgid "CONTROL_VIEW_BY_INPUT_SORTED" msgid "CONTROL_VIEW_BY_INPUT_SORTED"
msgstr ""
#, fuzzy
msgid "CONTROL_INPUT_ACTION"
msgstr "Cancel"
#, fuzzy
msgid "CONTROL_INPUT_VIEW"
msgstr "Cancel"
#, fuzzy
msgid "CONTROL_INPUT_OTHER"
msgstr "Cancel"
#, fuzzy
msgid "CONTROL_ADD_INPUT"
msgstr "Sort by input" msgstr "Sort by input"
#, fuzzy msgid "CONTROL_INPUT_ACTION"
msgstr "Action"
msgid "CONTROL_INPUT_VIEW"
msgstr "View"
msgid "CONTROL_INPUT_OTHER"
msgstr "Other"
msgid "CONTROL_ADD_INPUT"
msgstr "Add"
msgid "CONTROL_DEL_INPUT" msgid "CONTROL_DEL_INPUT"
msgstr "Cancel" msgstr "Del"
msgid "BUTTON_RIGHT" msgid "BUTTON_RIGHT"
msgstr "" msgstr "Button Right"
msgid "BUTTON_LEFT" msgid "BUTTON_LEFT"
msgstr "" msgstr "Button Left"
msgid "BUTTON_WHEEL_UP" msgid "BUTTON_WHEEL_UP"
msgstr "" msgstr "Button wheel up"
msgid "BUTTON_WHEEL_DOWN" msgid "BUTTON_WHEEL_DOWN"
msgstr "" msgstr "Button wheel down"
msgid "INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW" msgid "INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"
msgstr "" msgstr "Camera move and player follow"
msgid "INPUT_VIEW_CAMERA_MOVE_ONLY" msgid "INPUT_VIEW_CAMERA_MOVE_ONLY"
msgstr "" msgstr "Camera move only"
msgid "INPUT_ACTION_JUMP"
msgstr "Jump"

View file

@ -223,3 +223,6 @@ msgstr "Déplacer la caméra et le joueur suit"
msgid "INPUT_VIEW_CAMERA_MOVE_ONLY" msgid "INPUT_VIEW_CAMERA_MOVE_ONLY"
msgstr "Déplacer la caméra seulement" msgstr "Déplacer la caméra seulement"
msgid "INPUT_ACTION_JUMP"
msgstr "Sauter"

View file

@ -215,3 +215,5 @@ msgstr ""
msgid "INPUT_VIEW_CAMERA_MOVE_ONLY" msgid "INPUT_VIEW_CAMERA_MOVE_ONLY"
msgstr "" msgstr ""
msgid "INPUT_ACTION_JUMP"
msgstr ""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -23,6 +23,10 @@ const ZOOM_STEP_Y = 0.05
const ZOOM_STEP_Z = 0.1 const ZOOM_STEP_Z = 0.1
const ZOOM_MIN_Z = 0.2 const ZOOM_MIN_Z = 0.2
const ZOOM_MAX_Z = 3.0 const ZOOM_MAX_Z = 3.0
const ZOOM_DEFAULT = 1.0
const CAMERA_ROTATE_STEP_X = 0.02
const CAMERA_ROTATE_STEP_Y = 0.02
const SPEED_ROTATE = PI const SPEED_ROTATE = PI
const PI_2 = PI / 2.0 const PI_2 = PI / 2.0
@ -35,20 +39,25 @@ const FACTOR_WALK_WATER = 0.3
const MUL_SPEED_STEP = 0.2 const MUL_SPEED_STEP = 0.2
const SPEED_COLLIDED = 0.0001 const SPEED_COLLIDED = 0.0001
const MOVE_CAMERA_Y_STEP = 0.1
const MOVE_CAMERA_Y_MIN = -2.0
const MOVE_CAMERA_Y_MAX = 2.0
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes. # Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var starting_point = Vector2(DisplayServer.window_get_size().x / 2, DisplayServer.window_get_size().y / 2) var starting_point = Vector2(DisplayServer.window_get_size().x / 2, DisplayServer.window_get_size().y / 2)
# Camera position # Camera position
var camera_rotate_y = 0.0 var camera_rotate_y = 0.0
var camera_rotate_x = 0.0 var camera_rotate_x = 0.0
var camera_position_y = 0.0
# Player position # Player position
var player_rotate_y = 0.0 var player_rotate_y = 0.0
var player_rotate_x = 0.0 var player_rotate_x = 0.0
# Activate reconciliation between camera & player # Activate reconciliation between camera & player
var reconciliate_rotate_camera_player:bool = true var reconciliate_rotate_camera_player:bool = false
# Player run # Player run
var is_run:bool = false var is_run:bool = false
var zoom:float = 1.0 var zoom:float = ZOOM_DEFAULT
var tps:bool = true var tps:bool = true
var animation_object:AnimationPlayer = null var animation_object:AnimationPlayer = null
@ -216,7 +225,7 @@ func _input(event):
func _input_in_ship(event): func _input_in_ship(event):
if Input.is_action_just_pressed("board_ship"): if Input.is_action_just_pressed("INPUT_ACTION_ENTER_VEHICLE"):
on_ship = false on_ship = false
player_sit = false player_sit = false
return return
@ -224,7 +233,7 @@ func _input_in_ship(event):
func _input_player(event): func _input_player(event):
# Managed zoom (FPS or TPS) # Managed zoom (FPS or TPS)
if near_boat != null and Input.is_action_just_pressed("board_ship"): if near_boat != null and Input.is_action_just_pressed("INPUT_ACTION_ENTER_VEHICLE", true):
on_ship = true on_ship = true
player_sit = true player_sit = true
# emit_signal("switch_to_ship", near_boat) # emit_signal("switch_to_ship", near_boat)
@ -242,10 +251,58 @@ func _input_player(event):
#ranslate(diff) #ranslate(diff)
# translate(ship_pos) # translate(ship_pos)
global_translate(diff) global_translate(diff)
Common.msg_debug("res:" + str(get_global_transform().origin))
print("res:", get_global_transform().origin)
return return
if Input.is_action_just_pressed("switch_fps_tps"): if tps:
var pos:Vector3 = $camera_root.get_position()
var step_y = (Input.get_action_strength("INPUT_VIEW_UP", true) - Input.get_action_strength("INPUT_VIEW_DOWN", true)) * MOVE_CAMERA_Y_STEP
if step_y != 0.0 and camera_position_y + step_y <= MOVE_CAMERA_Y_MAX and camera_position_y + step_y >= MOVE_CAMERA_Y_MIN:
pos.y += step_y
camera_position_y += step_y
$camera_root.set_position(pos)
if Input.is_action_pressed("INPUT_VIEW_FRONT", true):
if tps:
# Recover rotate Y
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y )
camera_rotate_y = player_rotate_y
# Recover rotate X
$camera_root/horizontal_root/vertical_root.rotate_x( player_rotate_x - camera_rotate_x )
camera_rotate_x = player_rotate_x
# Recover zoom
var curzoom = zoom - ZOOM_DEFAULT
var fac = curzoom / ZOOM_STEP_Z
var zoom3D:Vector3 = Vector3(0.0, -fac * ZOOM_STEP_Y, -curzoom)
zoom = ZOOM_DEFAULT
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.translate_object_local(zoom3D)
# Position Camera on Y
var pos:Vector3 = $camera_root.get_position()
pos.y -= camera_position_y
$camera_root.set_position( pos )
camera_position_y = 0.0
elif Input.is_action_pressed("INPUT_VIEW_BACK", true):
if tps:
# Recover rotate Y
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y + PI )
camera_rotate_y = player_rotate_y + PI
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
# Recover rotate X
$camera_root/horizontal_root/vertical_root.rotate_x( player_rotate_x - camera_rotate_x )
camera_rotate_x = player_rotate_x
# Recover zoom
var curzoom = zoom - ZOOM_DEFAULT
var fac = curzoom / ZOOM_STEP_Z
var zoom3D:Vector3 = Vector3(0.0, -fac * ZOOM_STEP_Y, -curzoom)
zoom = ZOOM_DEFAULT
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.translate_object_local(zoom3D)
# Position Camera on Y
var pos:Vector3 = $camera_root.get_position()
pos.y -= camera_position_y
$camera_root.set_position( pos )
camera_position_y = 0.0
if Input.is_action_just_pressed("INPUT_VIEW_CAMERA_FPS_TPS", true):
if tps: if tps:
camera_fps.rotate_x( -player_rotate_x ) camera_fps.rotate_x( -player_rotate_x )
player_rotate_x = 0 player_rotate_x = 0
@ -259,7 +316,7 @@ func _input_player(event):
reconciliate_rotate_camera_player = true reconciliate_rotate_camera_player = true
tps = true tps = true
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.make_current() $camera_root/horizontal_root/vertical_root/Camera3D_TPS.make_current()
if Input.is_action_pressed("camera_zoom_in"): if Input.is_action_pressed("INPUT_VIEW_ZOOM_IN", true):
if tps: if tps:
if zoom > ZOOM_MIN_Z: if zoom > ZOOM_MIN_Z:
zoom -= ZOOM_STEP_Z zoom -= ZOOM_STEP_Z
@ -274,7 +331,7 @@ func _input_player(event):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y ) $camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y )
camera_rotate_y = player_rotate_y camera_rotate_y = player_rotate_y
elif Input.is_action_pressed("camera_zoom_out"): elif Input.is_action_pressed("INPUT_VIEW_ZOOM_OUT", true):
if not tps: if not tps:
# Reposition camera TPS back to player # Reposition camera TPS back to player
reconciliate_rotate_camera_player = true reconciliate_rotate_camera_player = true
@ -286,11 +343,11 @@ func _input_player(event):
else: else:
var zoom3D:Vector3 = Vector3(0.0, ZOOM_STEP_Y, ZOOM_STEP_Z) var zoom3D:Vector3 = Vector3(0.0, ZOOM_STEP_Y, ZOOM_STEP_Z)
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.translate_object_local(zoom3D) $camera_root/horizontal_root/vertical_root/Camera3D_TPS.translate_object_local(zoom3D)
elif Input.is_action_just_pressed("player_sit"): elif Input.is_action_just_pressed("INPUT_ACTION_SIT_DOWN", true):
player_sit = not player_sit player_sit = not player_sit
elif Input.is_action_just_pressed("player_automove"): elif Input.is_action_just_pressed("INPUT_ACTION_AUTO_UP", true):
player_automove = not player_automove player_automove = not player_automove
elif Input.is_action_just_pressed("switch_state_player"): elif Input.is_action_just_pressed("INPUT_ACTION_FLY", true):
match state_player: match state_player:
StatePlayer.WALK: StatePlayer.WALK:
switch_state(StatePlayer.FLY) switch_state(StatePlayer.FLY)
@ -300,18 +357,43 @@ func _input_player(event):
# If right mouse button is pressed and mouse moves, pan horizontally camera # If right mouse button is pressed and mouse moves, pan horizontally camera
# and rotate vertically # and rotate vertically
if tps: if tps:
if Input.is_action_just_pressed ( "ui_strafe" ): if Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
reconciliate_rotate_camera_player = false
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
elif Input.is_action_just_released ( "ui_strafe" ):
reconciliate_rotate_camera_player = true reconciliate_rotate_camera_player = true
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
elif Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
reconciliate_rotate_camera_player = false
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.is_action_just_pressed( "move_run" ): else:
is_run = true Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif Input.is_action_just_released( "move_run" ): # if Input.is_action_just_pressed ( "ui_strafe" ):
is_run = false # reconciliate_rotate_camera_player = false
# Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
# elif Input.is_action_just_released ( "ui_strafe" ):
# reconciliate_rotate_camera_player = true
# Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
# if Input.is_action_just_pressed( "move_run" ):
# is_run = true
# elif Input.is_action_just_released( "move_run" ):
# is_run = false
if Input.is_action_just_released("INPUT_ACTION_RUN", true):
is_run = !is_run
if Input.is_mouse_button_pressed( 2 ): if tps:
var camx = (Input.get_action_strength("INPUT_VIEW_CAMERA_UP", true) - Input.get_action_strength("INPUT_VIEW_CAMERA_DOWN", true)) * CAMERA_ROTATE_STEP_X
var new_camera_rotate_x = camera_rotate_x + camx
if new_camera_rotate_x <= PI_2 and new_camera_rotate_x >= - PI_2:
$camera_root/horizontal_root/vertical_root.rotate_x( camx )
camera_rotate_x = new_camera_rotate_x
var camy = (Input.get_action_strength("INPUT_VIEW_CAMERA_LEFT", true) - Input.get_action_strength("INPUT_VIEW_CAMERA_RIGHT", true)) * CAMERA_ROTATE_STEP_Y
camera_rotate_y -= camy
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
$camera_root/horizontal_root.rotate_y( -camy )
if Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW") or Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_ONLY"):
# if Input.is_mouse_button_pressed( 2 ):
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
if tps: if tps:
camera_rotate_y -= event.relative.x *0.01 camera_rotate_y -= event.relative.x *0.01
@ -386,28 +468,37 @@ func _physics_process_walk(delta):
motion_velocity.y -= gravity * delta motion_velocity.y -= gravity * delta
# Handle Jump. # Handle Jump.
if !jump_disabled and Input.is_action_just_pressed("ui_accept") and is_on_floor(): if !jump_disabled and Input.is_action_just_pressed("INPUT_ACTION_JUMP") and is_on_floor():
motion_velocity.y = JUMP_FORCE motion_velocity.y = JUMP_FORCE
jump_disabled = true jump_disabled = true
$TimerJump.start() $TimerJump.start()
# Get the input direction and handle the movement/deceleration. # Get the input direction and handle the movement/deceleration.
if Input.is_action_pressed("ui_strafe"): if Input.is_action_pressed("INPUT_ACTION_STRAFE_LEFT"):
if Input.is_action_pressed("ui_left"): input_x = 1.0
input_x = 1.0 move_strafe = true
move_strafe = true elif Input.is_action_pressed("INPUT_ACTION_STRAFE_RIGHT"):
elif Input.is_action_pressed("ui_right"): input_x = -1.0
input_x = -1.0 move_strafe = true
move_strafe = true
else: else:
var y = 0 input_x = 0.0
if Input.is_action_pressed("ui_right"): # if Input.is_action_pressed("ui_strafe"):
y -= 1 # if Input.is_action_pressed("ui_left"):
if Input.is_action_pressed("ui_left"): # input_x = 1.0
y += 1 # move_strafe = true
if y != 0: # elif Input.is_action_pressed("ui_right"):
var dt = y * delta * SPEED_ROTATE # input_x = -1.0
if tps: # move_strafe = true
var y = 0
if Input.is_action_pressed("INPUT_ACTION_RIGHT"):
y -= 1
if Input.is_action_pressed("INPUT_ACTION_LEFT"):
y += 1
if y != 0:
var dt = y * delta * SPEED_ROTATE
if tps:
if reconciliate_rotate_camera_player:
camera_rotate_y += dt camera_rotate_y += dt
if camera_rotate_y > PI: if camera_rotate_y > PI:
camera_rotate_y -= TAU camera_rotate_y -= TAU
@ -415,20 +506,30 @@ func _physics_process_walk(delta):
camera_rotate_y += TAU camera_rotate_y += TAU
$camera_root/horizontal_root.rotate_y( dt ) $camera_root/horizontal_root.rotate_y( dt )
else: else:
camera_rotate_y += dt
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
player_rotate_y += dt player_rotate_y += dt
if player_rotate_y > PI: if player_rotate_y > PI:
player_rotate_y -= TAU player_rotate_y -= TAU
elif player_rotate_y <= -PI: elif player_rotate_y <= -PI:
player_rotate_y += TAU player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt ) rotate_y( dt )
# Disable vector on ui_right/ui_left (used to rotate and not strafe) else:
input_x = 0 player_rotate_y += dt
if Input.is_action_pressed("ui_up"): if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
input_y = 1.0 input_y = 1.0
move_up = true move_up = true
player_automove = false player_automove = false
elif Input.is_action_pressed("ui_down"): elif Input.is_action_pressed("INPUT_ACTION_DOWN"):
player_automove = false player_automove = false
input_y = -1.0 input_y = -1.0
move_down = true move_down = true
@ -542,22 +643,23 @@ func _physics_process_walk_water(delta):
# motion_velocity.y = JUMP_FORCE # motion_velocity.y = JUMP_FORCE
# Get the input direction and handle the movement/deceleration. # Get the input direction and handle the movement/deceleration.
if Input.is_action_pressed("ui_strafe"): if Input.is_action_pressed("INPUT_ACTION_STRAFE_LEFT"):
if Input.is_action_pressed("ui_left"): input_x = 1.0
input_x = 1.0 move_strafe = true
move_strafe = true elif Input.is_action_pressed("INPUT_ACTION_STRAFE_RIGHT"):
elif Input.is_action_pressed("ui_right"): input_x = -1.0
input_x = -1.0 move_strafe = true
move_strafe = true
else: else:
var y = 0 input_x = 0.0
if Input.is_action_pressed("ui_right"): var y = 0
y -= 1 if Input.is_action_pressed("INPUT_ACTION_RIGHT"):
if Input.is_action_pressed("ui_left"): y -= 1
y += 1 if Input.is_action_pressed("INPUT_ACTION_LEFT"):
if y != 0: y += 1
var dt = y * delta * SPEED_ROTATE if y != 0:
if tps: var dt = y * delta * SPEED_ROTATE
if tps:
if reconciliate_rotate_camera_player:
camera_rotate_y += dt camera_rotate_y += dt
if camera_rotate_y > PI: if camera_rotate_y > PI:
camera_rotate_y -= TAU camera_rotate_y -= TAU
@ -565,20 +667,30 @@ func _physics_process_walk_water(delta):
camera_rotate_y += TAU camera_rotate_y += TAU
$camera_root/horizontal_root.rotate_y( dt ) $camera_root/horizontal_root.rotate_y( dt )
else: else:
camera_rotate_y += dt
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
player_rotate_y += dt player_rotate_y += dt
if player_rotate_y > PI: if player_rotate_y > PI:
player_rotate_y -= TAU player_rotate_y -= TAU
elif player_rotate_y <= -PI: elif player_rotate_y <= -PI:
player_rotate_y += TAU player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt ) rotate_y( dt )
# Disable vector on ui_right/ui_left (used to rotate and not strafe) else:
input_x = 0 player_rotate_y += dt
if Input.is_action_pressed("ui_up"): if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
input_y = 1.0 input_y = 1.0
move_up = true move_up = true
player_automove = false player_automove = false
elif Input.is_action_pressed("ui_down"): elif Input.is_action_pressed("INPUT_ACTION_DOWN"):
player_automove = false player_automove = false
input_y = -1.0 input_y = -1.0
move_down = true move_down = true
@ -662,22 +774,23 @@ func _physics_process_fly(delta):
var move_strafe: bool = false var move_strafe: bool = false
# Get the input direction and handle the movement/deceleration. # Get the input direction and handle the movement/deceleration.
if Input.is_action_pressed("ui_strafe"): if Input.is_action_pressed("INPUT_ACTION_STRAFE_LEFT"):
if Input.is_action_pressed("ui_left"): input_x = 1.0
input_x = 1.0 move_strafe = true
move_strafe = true elif Input.is_action_pressed("INPUT_ACTION_STRAFE_RIGHT"):
elif Input.is_action_pressed("ui_right"): input_x = -1.0
input_x = -1.0 move_strafe = true
move_strafe = true
else: else:
var y = 0 input_x = 0.0
if Input.is_action_pressed("ui_right"): var y = 0
y -= 1 if Input.is_action_pressed("INPUT_ACTION_RIGHT"):
if Input.is_action_pressed("ui_left"): y -= 1
y += 1 if Input.is_action_pressed("INPUT_ACTION_LEFT"):
if y != 0: y += 1
var dt = y * delta * SPEED_ROTATE if y != 0:
if tps: var dt = y * delta * SPEED_ROTATE
if tps:
if reconciliate_rotate_camera_player:
camera_rotate_y += dt camera_rotate_y += dt
if camera_rotate_y > PI: if camera_rotate_y > PI:
camera_rotate_y -= TAU camera_rotate_y -= TAU
@ -685,21 +798,31 @@ func _physics_process_fly(delta):
camera_rotate_y += TAU camera_rotate_y += TAU
$camera_root/horizontal_root.rotate_y( dt ) $camera_root/horizontal_root.rotate_y( dt )
else: else:
camera_rotate_y += dt
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
player_rotate_y += dt player_rotate_y += dt
if player_rotate_y > PI: if player_rotate_y > PI:
player_rotate_y -= TAU player_rotate_y -= TAU
elif player_rotate_y <= -PI: elif player_rotate_y <= -PI:
player_rotate_y += TAU player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt ) rotate_y( dt )
# Disable vector on ui_right/ui_left (used to rotate and not strafe) else:
input_x = 0 player_rotate_y += dt
if Input.is_action_pressed("ui_up"): if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
input_y = 1.0 input_y = 1.0
input_z = 1.0 input_z = 1.0
move_up = true move_up = true
player_automove = false player_automove = false
elif Input.is_action_pressed("ui_down"): elif Input.is_action_pressed("INPUT_ACTION_DOWN"):
player_automove = false player_automove = false
input_y = -1.0 input_y = -1.0
input_z = -1.0 input_z = -1.0
@ -791,22 +914,23 @@ func _physics_process_swim(delta):
var move_strafe: bool = false var move_strafe: bool = false
# Get the input direction and handle the movement/deceleration. # Get the input direction and handle the movement/deceleration.
if Input.is_action_pressed("ui_strafe"): if Input.is_action_pressed("INPUT_ACTION_STRAFE_LEFT"):
if Input.is_action_pressed("ui_left"): input_x = 1.0
input_x = 1.0 move_strafe = true
move_strafe = true elif Input.is_action_pressed("INPUT_ACTION_STRAFE_RIGHT"):
elif Input.is_action_pressed("ui_right"): input_x = -1.0
input_x = -1.0 move_strafe = true
move_strafe = true
else: else:
var y = 0 input_x = 0.0
if Input.is_action_pressed("ui_right"): var y = 0
y -= 1 if Input.is_action_pressed("INPUT_ACTION_RIGHT"):
if Input.is_action_pressed("ui_left"): y -= 1
y += 1 if Input.is_action_pressed("INPUT_ACTION_LEFT"):
if y != 0: y += 1
var dt = y * delta * SPEED_ROTATE if y != 0:
if tps: var dt = y * delta * SPEED_ROTATE
if tps:
if reconciliate_rotate_camera_player:
camera_rotate_y += dt camera_rotate_y += dt
if camera_rotate_y > PI: if camera_rotate_y > PI:
camera_rotate_y -= TAU camera_rotate_y -= TAU
@ -814,21 +938,31 @@ func _physics_process_swim(delta):
camera_rotate_y += TAU camera_rotate_y += TAU
$camera_root/horizontal_root.rotate_y( dt ) $camera_root/horizontal_root.rotate_y( dt )
else: else:
camera_rotate_y += dt
if camera_rotate_y > PI:
camera_rotate_y -= TAU
elif camera_rotate_y <= -PI:
camera_rotate_y += TAU
player_rotate_y += dt player_rotate_y += dt
if player_rotate_y > PI: if player_rotate_y > PI:
player_rotate_y -= TAU player_rotate_y -= TAU
elif player_rotate_y <= -PI: elif player_rotate_y <= -PI:
player_rotate_y += TAU player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt ) rotate_y( dt )
# Disable vector on ui_right/ui_left (used to rotate and not strafe) else:
input_x = 0 player_rotate_y += dt
if Input.is_action_pressed("ui_up"): if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( dt )
if Input.is_action_pressed("INPUT_ACTION_UP"):
input_y = 1.0 input_y = 1.0
input_z = 1.0 input_z = 1.0
move_up = true move_up = true
player_automove = false player_automove = false
elif Input.is_action_pressed("ui_down"): elif Input.is_action_pressed("INPUT_ACTION_DOWN"):
player_automove = false player_automove = false
input_y = -1.0 input_y = -1.0
input_z = -1.0 input_z = -1.0
@ -929,6 +1063,10 @@ func _process( delta ):
func _process_walk( delta ): func _process_walk( delta ):
if reconciliate_rotate_camera_player: if reconciliate_rotate_camera_player:
var diff = camera_rotate_y - player_rotate_y var diff = camera_rotate_y - player_rotate_y
if diff == 0.0:
reconciliate_rotate_camera_player = false
return
if diff > PI: if diff > PI:
diff = camera_rotate_y - player_rotate_y - TAU diff = camera_rotate_y - player_rotate_y - TAU

View file

@ -103,32 +103,32 @@ board_ship={
} }
INPUT_ACTION_UP={ INPUT_ACTION_UP={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"unicode":122,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_DOWN={ INPUT_ACTION_DOWN={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":115,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_LEFT={ INPUT_ACTION_LEFT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_RIGHT={ INPUT_ACTION_RIGHT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":100,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_STRAFE_LEFT={ INPUT_ACTION_STRAFE_LEFT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_STRAFE_RIGHT={ INPUT_ACTION_STRAFE_RIGHT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":69,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":69,"physical_keycode":0,"unicode":101,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_RUN={ INPUT_ACTION_RUN={
@ -156,6 +156,11 @@ INPUT_ACTION_ENTER_VEHICLE={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":88,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":88,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
INPUT_ACTION_JUMP={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":32,"echo":false,"script":null)
]
}
INPUT_VIEW_CAMERA_LEFT={ INPUT_VIEW_CAMERA_LEFT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
@ -188,12 +193,14 @@ INPUT_VIEW_DOWN={
} }
INPUT_VIEW_FRONT={ INPUT_VIEW_FRONT={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":true,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777229,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":true,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
INPUT_VIEW_BACK={ INPUT_VIEW_BACK={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":true,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777230,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":true,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
INPUT_VIEW_CAMERA_FPS_TPS={ INPUT_VIEW_CAMERA_FPS_TPS={

View file

@ -1,6 +1,24 @@
extends Node extends Node
var debug:bool = true
func msg_debug(text):
if debug:
var frame = get_stack()[1]
print("DEBUG [%s:%d] %s" % [frame.source, frame.line, text] )
func msg_info(text):
var frame = get_stack()[1]
print("INFO [%s:%d] %s" % [frame.source, frame.line, text] )
func msg_error(text):
var frame = get_stack()[1]
print("ERROR [%s:%d] %s" % [frame.source, frame.line, text] )
func get_string_input_mousse_button(event:InputEventMouseButton) -> String: func get_string_input_mousse_button(event:InputEventMouseButton) -> String:
match event.get_button_index(): match event.get_button_index():