【box3神奇代码岛】跑酷

@[TOC]1、制作水面

for (let i = 0; i < 306; ++i) {     
    for (let j = 0; j < 306; ++j) {         
        voxels.setVoxel(i, 8, j, 'water')
    } 
}

@[TOC]2、碰到水面重生

world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {//当玩家掉到水里
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    })
})

@[TOC]3、存档点

world.onPlayerJoin(({ entity }) => {
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.meshScale = e.meshScale.scale(1) //放大3倍
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
        if (other.isPlayer) { //另一个实体是玩家
            if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                other.player.directMessage('到达新的重生点') // 给玩家发消息
                other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
            }
        }
    }
        
})

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值