猫史档案馆


惊人发现!!!

用户:山衫惠子山衫惠子查看:2 回复:6 评论:2 创建时间:2020-01-27T22:08:43


 

加个点赞与关注,找个清泉不迷路。请复制以下代码:

//一个简单的射击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 + '打败了' + entity.player.name)

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

然后添加一个3D模型,运行程序,点击3D模型,你会发现,3D模型飞了!


回复

上一页1 页 / 共 1下一页
芜湖咸鱼芜湖咸鱼

你好像是抄的

点赞1


评论


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

我的世界叶子的名言

点赞0


评论


KaNSFKaNSF

我也惊呆了(doge)

点赞0


评论


刘lyxAndy刘lyxAndy

//在判断那里加一个isPlayer就行了

world.onPlayerJoin(({ entity }) => {

entity.enableDamage = true;

entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {

if (button !== 'action0' || !hitEntity||!hitEntity.isPlayer) {

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 + '打败了' + entity.player.name)

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

点赞0


评论


86135clc86135clc

楼主毁我图

点赞0


评论


星辰Lolita星辰Lolita

开挖

点赞0


评论