猫史档案馆


《汽车教程》

用户:azzzz代码师azzzz代码师查看:1 回复:3 评论:1 创建时间:2022-07-17T16:11:09


world.onPlayerJoin(({ entity }) => {//当玩家进入时
    /
    const originPlayerMesh = entity.mesh;//玩家
    world.onInteract(({ entity, targetEntity }) => {
 
 
        if (targetEntity.mesh.match("car") != 0) {
            entity.mesh = targetEntity.mesh;//玩家模型变成车
            entity.meshScale = targetEntity.meshScale;//大小一致
            entity.meshOrientation = targetEntity.meshOrientation;
            entity.position = targetEntity.position;//位置
            targetEntity.destroy();//原来的车销毁
            entity.player.invisible = true;
        }
 
    });
    ///上车
    world.onPress(({ button, raycast }) => {
        if (button === 'crouch') {
            const origincar = entity;
 
            //车
            world.createEntity({
                id: "car",
                mesh: origincar.mesh,
                mass: origincar.mass,
                friction: origincar.friction,
                position: origincar.position,
                meshScale: origincar.meshScale,
                restitution: origincar.restitution,
                meshOrientation: origincar.meshOrientation,
                collides: true,
                gravity: true,
                fixed: true,
            })
            //world.createEntity(car);
 
            entity.mesh = originPlayerMesh
            entity.player.invisible = false;//人物变为原来 注意顺序
        }
    })
 
})
world.onEntityCreate(({ entity }) => {//此时的entity的模型为载具
    if (entity.mesh.match("car") != 0) {
        //console.log("是车");
        entity.enableInteract = true;   // 开启实体互动功能
        entity.interactRadius = 8;     // 互动范围大小
    }
})
world.onEntityContact(({ entity, other }) => {//当一个实体碰撞到另一个实体时
 
}


回复

上一页1 页 / 共 1下一页
如风gvk如风gvk

合作么,https://box3.codemao.cn/e/56e33a7c14faf08f87ca

点赞0


评论


azzzz代码师azzzz代码师

关键是我大号用不了

点赞0


评论


含蓄的飓风雀E-zG含蓄的飓风雀E-zG

谢谢

 

点赞0


评论