猫史档案馆


【求助】谁会攻击距离为8格的PVP代码

用户:指令者指令者查看:20 回复:5 评论:20 创建时间:2021-02-27T20:29:38


如题,试了好多方法都不行emotion_编程猫_搓头


回复

上一页1 页 / 共 1下一页
BSS梅者如西BSS梅者如西

给你提供个思路

new Box3Vector3(x,y,z).distance(new Box3Vector3(x,y,z))

点赞0


评论


指令者指令者

还有一个就是进入一个区域设置

entity.enableDamage = true

点赞0


评论


治愈绾兮治愈绾兮

world.onPlayerJoin(({ entity }) => {
    entity.player.onPress(({ button, raycast: { hitEntity, direction, distance } }) => {
        if (button !== 'action0' || !hitEntity ||distance > 8) {
            return;
        }
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += 0.5;
        hitEntity.velocity.z += direction.z;
        hitEntity.hurt(20, {
            attacker: entity,
        });
    });
});

点赞0


评论


治愈绾兮治愈绾兮

这么简单,看楼下

点赞0


评论


BCMOJANGBCMOJANG

world.onClick(({ entity, clicker, distance }) => { 
    if (distance>5){//判断距离是否大于5(5可以改成任何数)
         return;
    }
    if (entity.isPlayer) { 
        
        world.say(`${clicker.player.name} 击中 ${entity.player.name}`)
    } else {
        world.say(distance)
        world.say(`${clicker.player.name} 击中 ${entity.id}`) 
    }

    entity.hurt(20)
    if(entity.hp<=0){
        world.say(`${entity.id} 被 ${clicker.player.name}送去见喵`)
         entity.destroy()
        
     }
    

点赞0


评论