Стартовый хаб с порталами, песочница отдельным пакетом, присед

- World/Hub: маленькая стартовая комната (код, без ассетов) с порталами на карты;
  новые карты добавляются записью в PORTALS (влезает 6 порталов).
- Песочница (main.tscn) вынесена в world.pck и качается при входе в портал;
  основной пакет игры вместо 19.7 МБ стал 2.1 МБ. Выходы из карт ведут в хаб.
- Экспорт: три пресета (Web — движок и хаб, World, Backrooms).
- Присед: удерживать C (на бегу Shift+C по-прежнему подкат), скорость 3.5.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 16:44:24 +05:00
co-authored by Claude Sonnet 5.5
parent 75aa525cb8
commit 9a4142419d
8 changed files with 224 additions and 10 deletions
+34 -3
View File
@@ -74,6 +74,8 @@ const SLIDE_COOLDOWN = 0.3
const SLIDE_CAMERA_DROP = 0.6
const SLIDE_HEIGHT_FACTOR = 0.5
const CROUCH_SPEED = 2.5 # Ползём, если над головой низкий потолок
const CROUCH_WALK_SPEED = 3.5 # Скорость в приседе (держим C; на бегу Shift+C — подкат)
const CROUCH_CAMERA_DROP = 0.6
const MIN_SLIDE_SPEED = 7.0 # Минимальная скорость для начала слайда
# --- Ступеньки ---
@@ -123,6 +125,7 @@ var bob_time: float = 0.0
# Состояние подката
var is_sliding: bool = false
var is_crouching: bool = false
var slide_cooldown_timer: float = 0.0
var slide_dir: Vector3 = Vector3.ZERO
var slide_speed: float = 0.0
@@ -248,7 +251,7 @@ func _unhandled_input(event: InputEvent) -> void:
# Битовые флаги состояния для сетевой синхронизации (см. Net.FLAG_*)
func get_net_flags() -> int:
var flags := 0
if is_sliding: flags |= Net.FLAG_SLIDING
if is_sliding or is_crouching: flags |= Net.FLAG_SLIDING # У призрака присед выглядит как сплюснутая капсула
if is_wallrunning: flags |= Net.FLAG_WALLRUN
if is_dashing: flags |= Net.FLAG_DASH
if is_mantling: flags |= Net.FLAG_MANTLE
@@ -277,6 +280,8 @@ func _physics_process(delta: float) -> void:
var space_down := Input.is_key_pressed(KEY_SPACE)
_update_crouch()
# --- Таймеры прыжка (coyote time + jump buffer) ---
if is_on_floor():
coyote_timer = COYOTE_TIME
@@ -338,7 +343,9 @@ func _physics_process(delta: float) -> void:
if is_wallrunning:
_wall_jump(wall_normal)
elif coyote_timer > 0.0:
if not is_sliding or _can_stand():
if (not is_sliding and not is_crouching) or _can_stand():
if is_crouching:
_end_crouch()
velocity.y = JUMP_VELOCITY
jump_buffer_timer = 0.0
coyote_timer = 0.0
@@ -360,7 +367,9 @@ func _physics_process(delta: float) -> void:
# 3. Скорость (Спринт)
var current_speed := WALK_SPEED
if Input.is_key_pressed(KEY_SHIFT):
if is_crouching:
current_speed = CROUCH_WALK_SPEED
elif Input.is_key_pressed(KEY_SHIFT):
current_speed = SPRINT_SPEED
# 4. Бег по стене
@@ -714,6 +723,7 @@ func _try_start_slide() -> void:
if horizontal.length() < MIN_SLIDE_SPEED:
return
is_crouching = false
is_sliding = true
slide_dir = horizontal.normalized()
slide_speed = clamp(max(horizontal.length() * SLIDE_START_MULT, SLIDE_START_SPEED), 0.0, MAX_SPEED)
@@ -744,6 +754,23 @@ func _process_slide(delta: float, direction: Vector3, horizontal: Vector3) -> Ve
return direction * CROUCH_SPEED
return horizontal.move_toward(Vector3.ZERO, CROUCH_SPEED)
# --- ПРИСЕД ---
# Держим C на земле — приседаем. Встаём, когда отпустили, и над головой есть место
func _update_crouch() -> void:
var busy := is_sliding or is_dashing or is_wallrunning or is_mantling or not is_on_floor()
if not is_crouching:
if Input.is_key_pressed(KEY_C) and not busy:
is_crouching = true
_set_collider_crouched(true)
elif (busy or not Input.is_key_pressed(KEY_C)) and (is_sliding or _can_stand()):
_end_crouch()
func _end_crouch() -> void:
is_crouching = false
if not is_sliding:
_set_collider_crouched(false)
func _end_slide() -> void:
is_sliding = false
slide_cooldown_timer = SLIDE_COOLDOWN
@@ -784,6 +811,8 @@ func _update_camera(delta: float, input_dir: Vector2) -> void:
var target_offset := 0.0
if is_sliding:
target_offset = -SLIDE_CAMERA_DROP
elif is_crouching:
target_offset = -CROUCH_CAMERA_DROP
elif is_mantling:
target_offset = -0.25
head_offset_y = lerp(head_offset_y, target_offset, 12.0 * delta)
@@ -879,6 +908,8 @@ func die() -> void:
death_timer = DEATH_TIME
if is_sliding:
_end_slide()
if is_crouching:
_end_crouch()
is_dashing = false
is_wallrunning = false
is_mantling = false