用户:
优雅的重金怪sy7q查看:4 回复:10 评论:4 创建时间:2022-12-18T09:59:47
怎么让玩家到终点后获得飞行
浩空星落world.onEntityContact(({entity,other})=>{//当发生碰撞事件
if(entity.isPlayer){//如果发起碰撞的实体是玩家
if(other.id=='奖杯'){//如果碰撞中的另一个实体是奖杯
entity.player.canFly=entity.player['\x6b\x69\x63\x6b'];//允许玩家飞行
world.say(entity.player.name+'通关了跑酷!');//还要播放广播
setTimeout(()=>entity.player.canFly(),2000)//让玩家更畅快的飞行
}
}
})点赞0
评论
人机47号or (const e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('奖杯')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
e.collides = true //开启碰撞
e.fixed = true //固定实体不被推移
e.meshScale = e.meshScale.scale(1) //放大1倍
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (e.position !== other.player.spawnPoint) {
other.player.canFly = true; // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
other.player.directMessage('恭喜你到达终点!获得飞行特权!') // 给玩家发消息
}
}
})
}
}
点赞0
评论
world.onEntityContact(({ entity, other }) => { // 当发生碰撞事件
if (entity.isPlayer) { // 如果发起碰撞的实体是玩家
if (other.id === '奖杯') { // 如果碰撞中的另一个实体是奖杯
entity.player.canFly = true; // 允许玩家飞行
world.say(entity.player.name + ' 通关了跑酷!'); // 播放广播
// 让玩家在2秒后恢复飞行状态
setTimeout(() => {
entity.player.canFly = false; // 取消飞行能力
world.say(entity.player.name + ' 的飞行能力已取消。'); // 广播飞行能力被取消
}, 2000);
}
}
});点赞0
评论
// 遍历所有实体,设置存档点和奖杯的碰撞逻辑
for (const e of world.querySelectorAll('*')) {
// 检查是否是存档点
if (e.id.startsWith('存档点')) {
e.collides = true; // 开启碰撞
e.fixed = true; // 固定实体不被推移
e.meshScale = e.meshScale.scale(1); // 放大1倍
// 为存档点添加碰撞检测
e.onEntityContact(({ other }) => {
if (other.isPlayer) { // 如果另一个实体是玩家
if (e.position !== other.player.spawnPoint) {
other.player.canFly = true; // 允许玩家飞行
other.player.directMessage('恭喜你到达终点!获得飞行特权!'); // 给玩家发消息
}
}
});
}
// 检查是否是奖杯
if (e.id === '奖杯') {
e.collides = true; // 开启碰撞
// 为奖杯添加碰撞检测
world.onEntityContact(({ entity, other }) => {
if (entity.isPlayer) { // 如果发起碰撞的实体是玩家
if (other.id === '奖杯') { // 如果碰撞中的另一个实体是奖杯
entity.player.canFly = true; // 允许玩家飞行
world.say(entity.player.name + '通关了跑酷!'); // 广播通关消息
setTimeout(() => {
entity.player.canFly = true; // 激活飞行特权
}, 2000); // 2秒后允许飞行
}
}
});
}
}
点赞0
评论
// 遍历所有实体,设置存档点和奖杯的碰撞逻辑 for (const e of world.querySelectorAll('*')) { // 检查是否是存档点 if (e.id.startsWith('存档点')) { e.collides = true; // 开启碰撞 e.fixed = true; // 固定实体不被推移 e.meshScale = e.meshScale.scale(1); // 放大1倍 // 为存档点添加碰撞检测 e.onEntityContact(({ other }) => { if (other.isPlayer) { // 如果另一个实体是玩家 if (e.position !== other.player.spawnPoint) { other.player.canFly = true; // 允许玩家飞行 other.player.directMessage('恭喜你到达终点!获得飞行特权!'); // 给玩家发消息 } } }); } // 检查是否是奖杯 if (e.id === '奖杯') { e.collides = true; // 开启碰撞 // 为奖杯添加碰撞检测 world.onEntityContact(({ entity, other }) => { if (entity.isPlayer) { // 如果发起碰撞的实体是玩家 if (other.id === '奖杯') { // 如果碰撞中的另一个实体是奖杯 entity.player.canFly = true; // 允许玩家飞行 world.say(entity.player.name + '通关了跑酷!'); // 广播通关消息 setTimeout(() => { entity.player.canFly = true; // 激活飞行特权 }, 2000); // 2秒后允许飞行 } } }); } }
点赞0
评论