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;