用户:
Chara_juchuief_exe查看:244 回复:12 评论:14 创建时间:2020-03-26T11:04:31
(function(/* 传送模块 */) {
// 存档点和传送点允许放置多个
// 传送点的实体需要加上标签 传送点
// 存档点的实体需要加上标签 存档点
// 存档点和传送点的实体需要开启 实体化
const checkPoint = {};
world.querySelectorAll('.存档点').forEach((e) => e.onEntityContact(({entity, other}) => {
if (other.isPlayer) {
checkPoint[other.player.name] = entity.position;//玩家碰到存档点,就会记录下玩家的名字,以及该存档点的位置
}
}));
world.querySelectorAll('.传送点').forEach((e) => e.onEntityContact(({entity, other}) => {
if (other.isPlayer && other.player.name in checkPoint) {
//如果玩家碰到传送点,且玩家的名字有记录在存档点,则传送玩家
other.position.copy(checkPoint[other.player.name]);
other.position.y += 40; // 传送到存档点的上方, 然后会自动落下
}
}));
})();这...找麻烦啊,还有超级简单的代码的...
点赞0
评论
但这可以永久保存...
能发一下吗
直接如果碰到存档点就储存在玩家的属性里...要用时就移动
你有传送代码吗
就是当碰到一个实体,传送到一个地点
entity.position.set(//此处可以直接填坐标对象,也可以分开三个值填x,y,z)
检测碰到一个实体呢?
world.querySelectorAll('.标签').forEach((e) => e.onEntityContact(({entity, other}) => {//要做的})
谢谢