猫史档案馆


【代码岛3.0】正着开车的代码

用户:hecoshecos查看:53 回复:22 评论:53 创建时间:2020-04-19T16:31:43


world.onEntityContact(({entity,other})=>{
    if(entity.isPlayer===false){
        if(other.isPlayer===true){
            if(entity.hasTag('car')){
                if(other.mesh===''){
                    other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
                    other.mesh=entity.mesh;
                    other.meshScale=entity.meshScale;
                    other.player.canFly=false;
                    other.player.invisible=true;
                    other.player.walkSpeed=2;
                    other.player.runSpeed=3;
                }
            }
        }
    }
});

给车加上car的标签

然后就可以正着开车啦!emotion_编程猫_加油emotion_编程猫_加油emotion_编程猫_加油


回复

上一页1 页 / 共 1下一页
神兽喵神兽喵

谢谢

点赞0


评论


Ken李Ken李

谢谢🙏

点赞0


评论


Moira屑玖iMoira屑玖i

!!!!!666666666666

点赞0


评论


机智的蓝雀机智的蓝雀

怎么下车

点赞0


评论


Vicent轩Vicent轩

怎么下车啊,就是碰到标签为 ofcar 的模型就复原(包括速度)。

回复时,回复给我的代码不要一行写完,非常感谢这位大佬哦~

点赞0


评论


hecoshecos

world.querySelectorAll('.ofcar').forEach((e)=>{
    e.onEntityContact(({other})=>{
        other.player.mesh='';
        other.player.invisible=false;
        other.player.walkSpeed=0.22;//正常行走速度
        other.player.runSpeed=0.4;//正常奔跑速度
        other.player.canFly=false;
    })
})//此代码不仅用于下车,也用于下任何交通工具,甚至不是交通工具

点赞0


评论


BSS梅者如西BSS梅者如西

额,补充一下飞机的代码,望置顶。首先先把模型加上“飞机”的标签,然后在代码栏里输入一下代码

world.onEntityContact(({entity,other})=>{
    if(entity.isPlayer===false){
        if(other.isPlayer===true){
            if(entity.hasTag('.飞机')){
                if(other.mesh===''){
                    other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
                    other.mesh=entity.mesh;
                    other.meshScale=entity.meshScale;
                    other.player.canFly=true;
                    other.player.invisible=true;
                    other.player.walkSpeed=2;
                    other.player.runSpeed=3;
                }
            }
        }
    }
});

点赞0


评论


硫酸QwQ硫酸QwQ

emotion_编程猫_点赞

点赞0


评论


ZCH编程小贝壳ZCH编程小贝壳

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true;
    entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
        if (button !== 'action0' || !hitEntity) {
            return;
        }
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += 0.5;
        hitEntity.velocity.z += direction.z;
        hitEntity.hurt(5 * Math.random() + 5, {
            attacker: entity,
        });
    });
});
//检测攻击代码
world.onDie(({ entity, attacker }) => {
    if (attacker) {
        world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
    }
    entity.player.forceRespawn();
});//死亡后代码

枪战代码emotion_doge

点赞0


评论


lon江航lon江航

emotion_编程猫_点赞

点赞0


评论


面具狐狸云绾兮面具狐狸云绾兮

开车....

我想到了什么......

点赞0


评论


BSS梅者如西BSS梅者如西

现在鱼动不来了!!!你快过来看看啊,链接是box3create.codemao.cn/games/bccd737d6ec213ccff29

点赞0


评论


GZ006GZ006

will!

点赞0


评论


DBsMarioDBsMario

咋搞碰到车系统说:谁谁谁变成了车

点赞0


评论


幻想一笑而过幻想一笑而过

center_image

emotion_doge

点赞0


评论


BSS梅者如西BSS梅者如西

AI在吗,我在https://box3create.codemao.cn/games/2fefcc6ce3ed8c052c40

点赞0


评论


BSS梅者如西BSS梅者如西

AI你到底在不在啊

点赞0


评论


BSS梅者如西BSS梅者如西

在吗在吗在吗?你是不是把鲁肃的大招做好了,起一个稍微炫酷一点的名字吧,等会给我演示下怎么用(每周天上午我都要上跆拳道,都来不了。)

点赞0


评论


BSS梅者如西BSS梅者如西

现在在吗??

点赞0


评论


BSS梅者如西BSS梅者如西

在吗在吗在吗?我刚刚在挂机

点赞0


评论


ZNS_哪吒ZNS_哪吒

。。

点赞0


评论


BSS梅者如西BSS梅者如西

AI,我找了几个大招看你能不能做出来。center_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_image

点赞0


评论