猫史档案馆


岛三如何交互开飞机(求代码)

用户:小鹿deer小鹿deer查看:4 回复:3 评论:4 创建时间:2021-12-19T18:16:15


交互开飞机,求代码(不是飞行,是开飞机)

 


回复

上一页1 页 / 共 1下一页
小鹿deer小鹿deer

求求了,真的不会

点赞0


评论


全能代码师全能代码师

好心帮你一把,不要抄袭(具体去问lolita,她的更nb)

点赞0


评论


全能代码师全能代码师

console.clear()
const planes = []
world.onPlayerJoin(({ entity }) => {
    const plane = world.createEntity({
        mesh: 'mesh/飞机.vb',
        collides: true,//碰撞
        gravity: false,//重力
        position: new Box3Vector3(喵, 喵, 喵),
        meshScale: new Box3Vector3(0.02, 0.02, 0.02),
    });
    entity.plane = plane;
    planes.push(plane)
    entity.up = 0;
    plane.speed = 3;
    entity.player.cameraEntity = plane
    entity.player.invisible = true;
    entity.player.spectator = true;
});
world.onTick(({ tick }) => {
    world.querySelectorAll('player').forEach((x) => {
        drive(x, x.plane)
    })
})
const plane_Quat = new Box3Quaternion(0, 0, 0, 1);
async function drive(entity, plane) {
    if (entity.player.jumpButton == true) {
        if (entity.up > -0.8) {
            entity.up -= 0.1
        }
    } else if (entity.player.crouchButton == true) {
        if (entity.up < 0.8) {
            entity.up += 0.1
        }
    }
    plane.meshOrientation = plane_Quat.rotateZ(entity.up).rotateY(Math.atan2(entity.player.facingDirection.z, entity.player.facingDirection.x) + Math.PI / 2)
    plane.position.y += -entity.up;
    plane.position.x += entity.player.facingDirection.x
    plane.position.z += entity.player.facingDirection.z
}

点赞0


评论