用户:
Xiaobao_o查看:1 回复:1 评论:1 创建时间:2021-07-16T12:55:34
代码如下 注存档点叫传送门-1~-5哈 entity.player.scale=0.25; for(consteofworld.querySelectorAll('*')){//遍历所有实体 if(e.id.startsWith('传送门')){//如果当前实体名左边部分刚好是"存档点",比如存档点-1存档点-2... e.collides=true;//开启碰撞 e.fixed=true//固定实体不被推移 e.meshScale=e.meshScale.scale(1)//放大2倍 e.onEntityContact(({other})=>{//每当存档点碰到另一个实体 if(other.isPlayer){//另一个实体是玩家 if(e.position!==other.player.spawnPoint){//检测当前存档点是否玩家重生点,避免反复在同一个存档点做多余的保存 other.player.directMessage('到达新的保存点,存档成功~')//给玩家发消息 other.player.spawnPoint=e.position//喵家重生点坐标设置成存档点的坐标 } } }) } } world.onPlayerJoin(({entity})=>{ entity.onFluidEnter(()=>{//当玩家掉到水里 entity.position.copy(entity.player.spawnPoint) entity.position.y+=4 }) }) //先在场景中放置一个名称为NPC的实体。 constnpc=world.querySelector('#npc'); npc.enableInteract=true; npc.interactHint=npc.id; npc.interactRadius=16; //玩家与实体进行交互时触发 npc.onInteract(async({entity})=>{ constresult=awaitentity.player.dialog({ type:Box3DialogType.SELECT, title:npc.id, lookTarget:npc, content:`${entity.player.name},你想尝试挑战这个游戏吗?`, options:['当然','下次吧。'], }); console.log(`选择了第index:${result.index}个选项:${result.value}`) //如果选了第一个选项,也就是'当然'。就会执行特定事件 if(result.index===0){ npc.say(`${result.value}?喵!`); world.onPlayerJoin(({entity})=>{ //玩家进入游戏的时候缩小到0.25倍 }) } });
Xiaobao_oentity.player.scale = 0.25;
for (c喵t e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('传送门')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
e.collides = true ;//开启碰撞
e.fixed = true //固定实体不被推移
e.meshScale = e.meshScale.scale(1) //放大2倍
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
other.player.directMessage('到达新的保存点,存档成功~') // 给玩家发消息
other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
}
}
})
}
}
world.onPlayerJoin(({ entity }) => {
entity.onFluidEnter(() => {//当玩家掉到水里
entity.position.copy(entity.player.spawnPoint)
entity.position.y += 4
})
})
// 先在场景中放置一个名称为 NPC 的实体。
c喵t npc = world.querySelector('#npc');
npc.enableInteract = true;
npc.interactHint = npc.id;
npc.interactRadius = 16;
// 玩家与实体进行交互时触发
npc.onInteract(async ({entity}) => {
c喵t result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: npc.id,
lookTarget:npc,
content: `${entity.player.name},你想尝试挑战这个游戏吗?`,
opti喵: ['当然', '下次吧。'],
});
c喵ole.log(`选择了第 index: ${result.index} 个选项: ${result.value}`)
// 如果选了第一个选项,也就是'当然'。就会执行特定事件
if (result.index === 0){
npc.say(`${result.value}?gun!`);
world.onPlayerJoin(({entity}) => {
// 玩家进入游戏的时候缩小到0.25倍
})
}
});
点赞0
评论