Implmented first/third person toggle via V
Deploy Promiscuity Auth API / deploy (push) Successful in 1m25s
Deploy Promiscuity Character API / deploy (push) Successful in 1m23s
Deploy Promiscuity Crafting API / deploy (push) Successful in 1m19s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m25s
Deploy Promiscuity Locations API / deploy (push) Successful in 1m26s
Deploy Promiscuity Mail API / deploy (push) Successful in 1m21s
Deploy Promiscuity World API / deploy (push) Successful in 1m21s
k8s smoke test / test (push) Successful in 20s
Deploy Promiscuity Auth API / deploy (push) Successful in 1m25s
Deploy Promiscuity Character API / deploy (push) Successful in 1m23s
Deploy Promiscuity Crafting API / deploy (push) Successful in 1m19s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m25s
Deploy Promiscuity Locations API / deploy (push) Successful in 1m26s
Deploy Promiscuity Mail API / deploy (push) Successful in 1m21s
Deploy Promiscuity World API / deploy (push) Successful in 1m21s
k8s smoke test / test (push) Successful in 20s
This commit is contained in:
@@ -116,6 +116,11 @@ player_phone={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194306,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
player_toggle_perspective={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":118,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
interact={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||
|
||||
@@ -2,6 +2,8 @@ extends Node
|
||||
|
||||
var _requested_spawn_name: StringName = &""
|
||||
var camera_zoom_dist: float = 3.0
|
||||
var third_person_camera_zoom_dist: float = 3.0
|
||||
var camera_is_first_person: bool = false
|
||||
|
||||
|
||||
func request_spawn(spawn_name: StringName) -> void:
|
||||
|
||||
+59
-15
@@ -15,7 +15,11 @@ const DEFAULT_ZOOM_DIST := 3.0
|
||||
const MIN_ZOOM_DIST := 1.5
|
||||
const MAX_ZOOM_DIST := 8.0
|
||||
const ZOOM_STEP := 0.5
|
||||
const FIRST_PERSON_HEIGHT := 1.6
|
||||
const MODEL_SHOW_CAMERA_DISTANCE := 0.75
|
||||
var _zoom_dist := DEFAULT_ZOOM_DIST
|
||||
var _third_person_zoom_dist := DEFAULT_ZOOM_DIST
|
||||
var _is_first_person := false
|
||||
const FIREBALL_SPAWN_FORWARD_OFFSET := 1.5
|
||||
const FIREBALL_SPAWN_UP_OFFSET := 1.2
|
||||
var mouse_sensitivity := 0.005
|
||||
@@ -71,7 +75,13 @@ func _ready() -> void:
|
||||
audio_player.volume_db = -20
|
||||
if cam:
|
||||
if TeleportState != null:
|
||||
_zoom_dist = TeleportState.camera_zoom_dist
|
||||
_third_person_zoom_dist = clampf(
|
||||
TeleportState.third_person_camera_zoom_dist,
|
||||
MIN_ZOOM_DIST,
|
||||
MAX_ZOOM_DIST
|
||||
)
|
||||
_is_first_person = TeleportState.camera_is_first_person or TeleportState.camera_zoom_dist == 0.0
|
||||
_zoom_dist = 0.0 if _is_first_person else _third_person_zoom_dist
|
||||
_camera_pitch = cam.rotation.x
|
||||
_camera_yaw = global_transform.basis.get_euler().y
|
||||
cam.set_as_top_level(true)
|
||||
@@ -160,8 +170,7 @@ func _integrate_forces(state):
|
||||
cam.global_position = cam.global_position.lerp(target_pos, camera_follow_speed * state.step)
|
||||
cam.global_rotation = Vector3(_camera_pitch, _camera_yaw, 0.0)
|
||||
|
||||
if _model_root:
|
||||
_model_root.visible = (_zoom_dist > 0.0) and not _in_vehicle
|
||||
_update_model_visibility()
|
||||
|
||||
_update_animation(on_floor, state.linear_velocity)
|
||||
_jump_triggered = false
|
||||
@@ -180,6 +189,10 @@ func _input(event):
|
||||
if _in_vehicle:
|
||||
return
|
||||
|
||||
if event.is_action_pressed("player_toggle_perspective"):
|
||||
set_first_person(not _is_first_person)
|
||||
return
|
||||
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
_pending_mouse_delta += event.relative
|
||||
|
||||
@@ -200,29 +213,60 @@ func zoom_camera(zoom_in: bool) -> void:
|
||||
if cam == null:
|
||||
return
|
||||
if zoom_in:
|
||||
if _zoom_dist == 0.0:
|
||||
if _is_first_person:
|
||||
return
|
||||
elif _zoom_dist <= MIN_ZOOM_DIST:
|
||||
_zoom_dist = 0.0
|
||||
set_first_person(true)
|
||||
return
|
||||
else:
|
||||
_zoom_dist = max(MIN_ZOOM_DIST, _zoom_dist - ZOOM_STEP)
|
||||
else:
|
||||
if _zoom_dist == 0.0:
|
||||
_zoom_dist = MIN_ZOOM_DIST
|
||||
if _is_first_person:
|
||||
set_first_person(false)
|
||||
return
|
||||
else:
|
||||
_zoom_dist = min(MAX_ZOOM_DIST, _zoom_dist + ZOOM_STEP)
|
||||
|
||||
if TeleportState != null:
|
||||
TeleportState.camera_zoom_dist = _zoom_dist
|
||||
|
||||
|
||||
_third_person_zoom_dist = _zoom_dist
|
||||
_persist_camera_state()
|
||||
update_camera_offset()
|
||||
|
||||
func set_first_person(enabled: bool) -> void:
|
||||
if enabled == _is_first_person:
|
||||
return
|
||||
if enabled and _zoom_dist > 0.0:
|
||||
_third_person_zoom_dist = _zoom_dist
|
||||
_is_first_person = enabled
|
||||
_zoom_dist = 0.0 if enabled else _third_person_zoom_dist
|
||||
_persist_camera_state()
|
||||
update_camera_offset()
|
||||
_update_model_visibility()
|
||||
|
||||
func _persist_camera_state() -> void:
|
||||
if TeleportState == null:
|
||||
return
|
||||
TeleportState.camera_is_first_person = _is_first_person
|
||||
TeleportState.camera_zoom_dist = _zoom_dist
|
||||
TeleportState.third_person_camera_zoom_dist = _third_person_zoom_dist
|
||||
|
||||
func update_camera_offset() -> void:
|
||||
if _zoom_dist == 0.0:
|
||||
_camera_offset_local = Vector3(0.0, 1.6, 0.0)
|
||||
if _is_first_person:
|
||||
_camera_offset_local = Vector3(0.0, FIRST_PERSON_HEIGHT, 0.0)
|
||||
else:
|
||||
var height_offset := 0.25 * _zoom_dist
|
||||
_camera_offset_local = Vector3(0.5, 1.6 + height_offset, _zoom_dist)
|
||||
_camera_offset_local = Vector3(0.5, FIRST_PERSON_HEIGHT + height_offset, _zoom_dist)
|
||||
|
||||
func _update_model_visibility() -> void:
|
||||
if _model_root == null:
|
||||
return
|
||||
if _in_vehicle or _is_first_person:
|
||||
_model_root.visible = false
|
||||
return
|
||||
if cam == null:
|
||||
_model_root.visible = true
|
||||
return
|
||||
var eye_position := global_position + Vector3.UP * FIRST_PERSON_HEIGHT
|
||||
_model_root.visible = cam.global_position.distance_to(eye_position) >= MODEL_SHOW_CAMERA_DISTANCE
|
||||
|
||||
func shoot_fireball() -> void:
|
||||
var direction := get_look_direction()
|
||||
@@ -286,7 +330,7 @@ func exit_vehicle(exit_point: Node3D, vehicle_camera: Camera3D) -> void:
|
||||
_vehicle_original_parent = null
|
||||
_flashlight.visible = _light_was_on
|
||||
if _model_root:
|
||||
_model_root.visible = true
|
||||
_model_root.visible = not _is_first_person
|
||||
if exit_point:
|
||||
global_transform = exit_point.global_transform
|
||||
if vehicle_camera:
|
||||
|
||||
Reference in New Issue
Block a user