猫史档案馆


BOX3.0PVP代码是什么???

用户:编程猫编程猫查看:1 回复:2 评论:1 创建时间:2020-02-23T10:48:14


          


回复

上一页1 页 / 共 1下一页
LUS圣武士LUS圣武士

//一个简单的射击PvP
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(20 * Math.random() + 5, {

attacker: entity,

});
});
});


world.onDie(({ entity, attacker }) => {

if (attacker) {

world.say(attacker.player.name + ' killed ' + entity.player.name)

}
entity.player.forceRespawn();
});

点赞0


评论


LUS圣武士LUS圣武士

这个吗

点赞0


评论