update camera view front on touch pressed
This commit is contained in:
parent
20c7130b01
commit
dfc52c1857
9 changed files with 99 additions and 22 deletions
|
@ -170,6 +170,9 @@ msgstr "View front"
|
||||||
msgid "INPUT_VIEW_BACK"
|
msgid "INPUT_VIEW_BACK"
|
||||||
msgstr "View back"
|
msgstr "View back"
|
||||||
|
|
||||||
|
msgid "INPUT_VIEW_BACK_ONLY_PRESSED"
|
||||||
|
msgstr "View back (on pressed)"
|
||||||
|
|
||||||
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
||||||
msgstr "First person / Third person"
|
msgstr "First person / Third person"
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,9 @@ msgstr "Recentrer la caméra derrière le personnage"
|
||||||
msgid "INPUT_VIEW_BACK"
|
msgid "INPUT_VIEW_BACK"
|
||||||
msgstr "Regarder derrière soi"
|
msgstr "Regarder derrière soi"
|
||||||
|
|
||||||
|
msgid "INPUT_VIEW_BACK_ONLY_PRESSED"
|
||||||
|
msgstr "Regarder derrière soi (touche enfoncée)"
|
||||||
|
|
||||||
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
||||||
msgstr "1ère/3ème personne"
|
msgstr "1ère/3ème personne"
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -161,6 +161,9 @@ msgstr ""
|
||||||
msgid "INPUT_VIEW_BACK"
|
msgid "INPUT_VIEW_BACK"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "INPUT_VIEW_BACK_ONLY_PRESSED"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
msgid "INPUT_VIEW_CAMERA_FPS_TPS"
|
||||||
msgstr ""
|
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
|
@ -30,7 +30,7 @@ const ZOOM_MAX_Z = 3.0
|
||||||
const ZOOM_DEFAULT = 1.0
|
const ZOOM_DEFAULT = 1.0
|
||||||
|
|
||||||
const CAMERA_TPS_ROTATE_STEP_X = 0.5
|
const CAMERA_TPS_ROTATE_STEP_X = 0.5
|
||||||
const CAMERA_TPS_ROTATE_STEP_Y = 0.5
|
const CAMERA_TPS_ROTATE_STEP_Y = 1.0
|
||||||
|
|
||||||
const CAMERA_FPS_ROTATE_STEP_X = 10.0
|
const CAMERA_FPS_ROTATE_STEP_X = 10.0
|
||||||
const CAMERA_FPS_ROTATE_STEP_Y = 10.0
|
const CAMERA_FPS_ROTATE_STEP_Y = 10.0
|
||||||
|
@ -168,6 +168,63 @@ var offset_camera_fly:float = 0.0
|
||||||
var offset_camera_swim:float = 0.0
|
var offset_camera_swim:float = 0.0
|
||||||
|
|
||||||
|
|
||||||
|
var save_enabled:bool = false
|
||||||
|
var save_tps:bool = true
|
||||||
|
var save_camera_rotate_x:float
|
||||||
|
var save_camera_rotate_y:float
|
||||||
|
var save_camera_position_y:float
|
||||||
|
var save_zoom:float
|
||||||
|
|
||||||
|
|
||||||
|
func save_position_camera():
|
||||||
|
#Common.msg_debug("Save pos camera")
|
||||||
|
save_tps = tps
|
||||||
|
save_camera_rotate_x = camera_rotate_x
|
||||||
|
save_camera_rotate_y = camera_rotate_y
|
||||||
|
save_zoom = zoom
|
||||||
|
save_camera_position_y = camera_position_y
|
||||||
|
save_enabled = true
|
||||||
|
|
||||||
|
|
||||||
|
func restore_position_camera():
|
||||||
|
if ! save_enabled:
|
||||||
|
return
|
||||||
|
if save_tps:
|
||||||
|
restore_camera_tps()
|
||||||
|
else:
|
||||||
|
switch_camera_fps()
|
||||||
|
save_enabled = false
|
||||||
|
|
||||||
|
|
||||||
|
func restore_camera_tps():
|
||||||
|
#Common.msg_debug("restore_camera_tps")
|
||||||
|
tps = true
|
||||||
|
reconciliate_rotate_camera_player = false
|
||||||
|
# Recover rotate Y
|
||||||
|
$camera_root/horizontal_root.rotate_y( save_camera_rotate_y - camera_rotate_y )
|
||||||
|
camera_rotate_y = save_camera_rotate_y
|
||||||
|
# Recover rotate X
|
||||||
|
$camera_root/horizontal_root/vertical_root.rotate_x( save_camera_rotate_x - camera_rotate_x )
|
||||||
|
camera_rotate_x = save_camera_rotate_x
|
||||||
|
# Recover zoom
|
||||||
|
var zoomorign = save_zoom
|
||||||
|
var curzoom = save_zoom - ZOOM_MIN_Z
|
||||||
|
var fac = curzoom / ZOOM_STEP_Z
|
||||||
|
var zoom3D:Vector3 = Vector3(0.0, -fac * ZOOM_STEP_Y, -curzoom)
|
||||||
|
zoom = ZOOM_MIN_Z
|
||||||
|
$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 - save_camera_position_y
|
||||||
|
$camera_root.set_position( pos )
|
||||||
|
camera_position_y = save_camera_position_y
|
||||||
|
# Move slowly the camera to detect collision (and stop camera)
|
||||||
|
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.make_current()
|
||||||
|
var last_zoom = 0.0
|
||||||
|
while zoom < zoomorign and zoom != last_zoom:
|
||||||
|
last_zoom = zoom
|
||||||
|
camera_zoom_out()
|
||||||
|
|
||||||
func switch_state(new_state):
|
func switch_state(new_state):
|
||||||
if state_player == new_state:
|
if state_player == new_state:
|
||||||
return
|
return
|
||||||
|
@ -344,6 +401,11 @@ func get_distance_vector(obj1: Vector3, obj2: Vector3) -> float:
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
if Input.is_action_just_pressed("INPUT_VIEW_BACK_ONLY_PRESSED", true):
|
||||||
|
save_position_camera()
|
||||||
|
switch_camera_tps_back()
|
||||||
|
elif Input.is_action_just_released("INPUT_VIEW_BACK_ONLY_PRESSED", true):
|
||||||
|
restore_position_camera()
|
||||||
if tps:
|
if tps:
|
||||||
if Input.is_action_pressed("INPUT_VIEW_FRONT", true) and tps:
|
if Input.is_action_pressed("INPUT_VIEW_FRONT", true) and tps:
|
||||||
# Move camera position on front
|
# Move camera position on front
|
||||||
|
@ -432,7 +494,7 @@ func switch_camera_fps():
|
||||||
|
|
||||||
|
|
||||||
func switch_camera_tps():
|
func switch_camera_tps():
|
||||||
#Common.msg_debug("switch_camera_tps")
|
Common.msg_debug("switch_camera_tps")
|
||||||
tps = true
|
tps = true
|
||||||
reconciliate_rotate_camera_player = true
|
reconciliate_rotate_camera_player = true
|
||||||
# Recover rotate Y
|
# Recover rotate Y
|
||||||
|
@ -462,6 +524,7 @@ func switch_camera_tps():
|
||||||
|
|
||||||
|
|
||||||
func switch_camera_tps_front():
|
func switch_camera_tps_front():
|
||||||
|
#Common.msg_debug("switch_camera_tps_front")
|
||||||
# Recover rotate Y
|
# Recover rotate Y
|
||||||
$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
|
||||||
|
@ -487,6 +550,7 @@ func switch_camera_tps_front():
|
||||||
|
|
||||||
|
|
||||||
func switch_camera_tps_back():
|
func switch_camera_tps_back():
|
||||||
|
#Common.msg_debug("switch_camera_tps_back")
|
||||||
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y + PI )
|
$camera_root/horizontal_root.rotate_y( player_rotate_y - camera_rotate_y + PI )
|
||||||
camera_rotate_y = player_rotate_y + PI
|
camera_rotate_y = player_rotate_y + PI
|
||||||
if camera_rotate_y > PI:
|
if camera_rotate_y > PI:
|
||||||
|
@ -1035,7 +1099,7 @@ func _process( delta ):
|
||||||
switch_state(StatePlayer.SWIM)
|
switch_state(StatePlayer.SWIM)
|
||||||
mulstep = FACTOR_SWIM
|
mulstep = FACTOR_SWIM
|
||||||
StatePlayer.WALK:
|
StatePlayer.WALK:
|
||||||
Common.msg_debug("WALK")
|
#Common.msg_debug("WALK")
|
||||||
mulstep = FACTOR_WALK
|
mulstep = FACTOR_WALK
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
velocity.y -= gravity * delta
|
velocity.y -= gravity * delta
|
||||||
|
|
|
@ -205,7 +205,11 @@ INPUT_VIEW_FRONT={
|
||||||
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":false,"pressed":false,"keycode":16777230,"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_BACK_ONLY_PRESSED={
|
||||||
|
"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)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
INPUT_VIEW_CAMERA_FPS_TPS={
|
INPUT_VIEW_CAMERA_FPS_TPS={
|
||||||
|
|
Loading…
Reference in a new issue