用户:满月居于夜空查看:9 回复:6 评论:9 创建时间:2022-01-26T13:09:14
如题,就是允许玩家交互。如果交互了,被交互的玩家就扣100血量
本人只会这一点点

浮生awaconst npc = world.querySelector('#你要交互模型的名字');
npc.enableInteract = true; // 开启实体互动功能
npc.interactHint = '交互文字';
npc.interactRadius = 32;
world.onInteract( ({entity}) => {
entity.enableDamage = true
entity.hurt(伤害值)
});点赞0
评论
研岩 world.onPlayerJoin(({ entity }) => {
entity.enableInteract = true;
entity.interactHint="player"
entity.interactColor = new Box3RGBColor(0.4,0.4,1)
entity.onInteract(async({entity,targetEntity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: targetEntity.player.name,
content: `${entity.player.name}`,
options: "a", //
});
if(!result || result==null){
return
}
});
});点赞0
评论