fix(lua): player:LoadCharacter() / hrp.Position телепортируют через player._pos
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 нет.
This commit is contained in:
parent
bec3c478e7
commit
f18835d5e9
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user