From f18835d5e97c355b9c65cec86258493fa065dcbf Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 18:40:20 +0300 Subject: [PATCH] =?UTF-8?q?fix(lua):=20player:LoadCharacter()=20/=20hrp.Po?= =?UTF-8?q?sition=20=D1=82=D0=B5=D0=BB=D0=B5=D0=BF=D0=BE=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D1=83=D1=8E=D1=82=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20pla?= =?UTF-8?q?yer.=5Fpos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GameRuntime обрабатывал prop:'position' и prop:'respawn' через player.body.position.set() — но PlayerController хранит позицию в player._pos (не body). Поэтому LoadCharacter молча ничего не делал. Фикс: ставим player._pos.set(x, y+halfH, z) + сброс _vy. Fallback на body если _pos нет. --- src/editor/engine/GameRuntime.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/editor/engine/GameRuntime.js b/src/editor/engine/GameRuntime.js index b051df0..a56b27d 100644 --- a/src/editor/engine/GameRuntime.js +++ b/src/editor/engine/GameRuntime.js @@ -4357,19 +4357,29 @@ export class GameRuntime { // Lua-вызов hrp.Position = ... — телепорт игрока try { const v = payload.value || {}; - if (player.body && player.body.position) { + const halfH = player.HALF_H ?? 0.9; + if (player._pos) { + player._pos.set(v.x || 0, (v.y || 0) + halfH, v.z || 0); + if (player._vy != null) player._vy = 0; + } else if (player.body?.position?.set) { player.body.position.set(v.x || 0, v.y || 0, v.z || 0); } } catch (_) {} } else if (payload.prop === 'respawn') { // Lua-вызов player:LoadCharacter() — телепорт к spawn и сброс HP try { - if (typeof player.respawn === 'function') player.respawn(); - else { + if (typeof player.respawn === 'function') { + player.respawn(); + } else { const sp = this.scene3d?.projectData?.scene?.spawnPoint || this.projectData?.scene?.spawnPoint || { x: 0, y: 5, z: 0 }; - if (player.body && player.body.position) { + // PlayerController хранит позицию в player._pos. + const halfH = player.HALF_H ?? 0.9; + if (player._pos) { + player._pos.set(sp.x, sp.y + halfH, sp.z); + if (player._vy != null) player._vy = 0; + } else if (player.body?.position?.set) { player.body.position.set(sp.x, sp.y, sp.z); } player.hp = player.maxHp || 100;