猫史档案馆


为什么这个报错?(无法读取hp)

用户:KO轩awaKO轩awa查看:0 回复:1 评论:0 创建时间:2024-02-01T15:41:58


require("./地形.js")
try{
world.onPlayerJoin(({entity})=>{
    entity.enableDamage = true;
    entity.maxHp=100;entity.hp=entity.maxHp;
    entity.player.runSpeed=0.3;
    entity.player.jumpAccelerationFactor=1.3;
    entity.player.jumpPower=0.6;
    entity.player.enableDoubleJump = false;
    entity.player.cameraFovY = 0.5;
    entity.player.cameraMode = "FPS";
    entity.hurt(0);
})

world.onClick(({entity,hitEntity})=>{
    if(hitEntity.hp>0){
        hitEntity.hurt(8);
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += 1.2;
        hitEntity.velocity.z += direction.z;
    }else{
        hitEntity.velocity.x += direction.x += direction.x += direction.x;
        hitEntity.velocity.y += 3.6;
        hitEntity.velocity.z += direction.z += direction.z += direction.z;
    }
})
}catch(Error){
    world.say(Error);
}


回复

上一页1 页 / 共 1下一页
yh12i31yh12i31

你似乎把onPress事件和onClick事件搞混了

world.onClick(({ clicker, entity }) => {
    // clicker:点击按键的玩家
    // entity:被点击到的玩家
});
world.onPress(({ entity, raycast }) => {
    const hitEntity = raycast.hitEntity;
    // entity:点击按键的玩家
    // hitEntity:被点击到的玩家
});

点赞0


评论