update #14 - touche Avancé qui recadre la caméra

This commit is contained in:
AleaJactaEst 2022-03-30 00:43:02 +02:00
parent 1c115ac66e
commit b58bcca228
4 changed files with 43 additions and 19 deletions

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

@ -66,6 +66,7 @@ var player_rotate_y = 0.0
var player_rotate_x = 0.0
# Activate reconciliation between camera & player
var reconciliate_rotate_camera_player:bool = false
var reconciliate_rotate_player_back:bool = false
var move_camera_back_player:bool = false
# Player run
var is_run:bool = false
@ -920,7 +921,28 @@ func _process( delta ):
if offset_camera_current != offset_camera_target:
var offset_diff = move_camera_y_one_step( offset_camera_target - offset_camera_current, MOVE_CAMERA_Y_OFFSET)
offset_camera_current += offset_diff
if reconciliate_rotate_camera_player:
if reconciliate_rotate_player_back:
var diff = camera_rotate_y - player_rotate_y
if not Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
if diff <= 0.01 and diff >= -0.01:
reconciliate_rotate_player_back = false
return
if diff > PI:
diff = camera_rotate_y - player_rotate_y - TAU
elif diff < -PI:
diff = camera_rotate_y - player_rotate_y + TAU
var absdiff = diff
if absdiff < 0.0:
absdiff = -absdiff
if absdiff <= 0.5 * delta:
rotate_camera_y(diff)
else:
if diff >= 0.0:
diff = delta * SPEED_ROTATE
else:
diff = -delta * SPEED_ROTATE
rotate_camera_y(diff)
elif reconciliate_rotate_camera_player:
var diff = camera_rotate_y - player_rotate_y
if not Input.is_action_pressed("INPUT_VIEW_CAMERA_MOVE_PLAYER_FOLLOW"):
if diff <= 0.01 and diff >= -0.01:
@ -1010,6 +1032,8 @@ func _process( delta ):
input_y = 1.0
input_z = 1.0
move_up = true
if Input.is_action_pressed("INPUT_ACTION_UP"):
reconciliate_rotate_player_back = true
elif Input.is_action_pressed("INPUT_ACTION_DOWN"):
player_automove = false
input_y = -1.0