猫史档案馆


如何在玩家碰到某个实体时让玩家开启飞行呢?

用户:斯文的力士甲虫_B6N斯文的力士甲虫_B6N查看:5 回复:4 评论:5 创建时间:2022-02-09T16:10:25


如题

来自萌新的疑惑


回复

上一页1 页 / 共 1下一页
yee089yee089

world.onEntityContect(({entity,other)}=>{

           if(entity.id=' ')//你要的实体的名称
    
                    if(other.isPlayer)
                         other.canFly=true;

})

点赞0


评论


yee089yee089

world.onEntityContact(({entity,other})=>{

           if(entity.id=' ')//你要的实体的名称 要开可碰撞!!!!
    
                    if(other.isPlayer)
                         other.player.canFly=true;

})

debug完了))应该没事了

点赞0


评论


橙子nUcg橙子nUcg

我整理了一下楼下的代码,这样:

world.onEntityContact(({entity,other})=>{ //实体碰撞事件
    if(other.isPlayer){ //如果其中一个实体是玩家
        if(!entity.isPlayer){ //如果另一个实体不是玩家(这样保险一点)
            if(entity.id == '实体'){ //实体是要碰撞的实体名字(记住实体要开碰撞)
                other.player.canFly = true; //玩家开启飞行
            } 
        }
    }
})

点赞1


评论


东方绝尘东方绝尘

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%86%B7%E6%BC%A0.gif"alt="emotion_编程猫_冷漠"

点赞0


评论