猫史档案馆


代码教程更新啦~ 如何做跑酷

用户:jlmbcjlmbc查看:0 回复:2 评论:0 创建时间:2021-05-15T20:00:37


部分代码如下:

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

world.onVoxelContact(({ x, y, z, voxel,entity }) => {
    const voxelName = voxels.name(voxel);  // 将方块id转换名称
    if (voxelName === 'white'){              // 如果方块名称是F
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    }
});

world.onVoxelContact(({ x, y, z, voxel,entity }) => {
    const voxelName = voxels.name(voxel);  // 将方块id转换名称
    if (voxelName === 'S'){              // 如果方块名称是F
        world.say(`${entity.player.name}开始了酷跑!`)
    }
});


回复

上一页1 页 / 共 1下一页
jlmbcjlmbc

没有录完,只是部分代码,可以自己改

点赞0


评论


大德意志方片大德意志方片

emotion_编程猫_厉害了

点赞0


评论