用户:
小白鸡查看:0 回复:2 评论:0 创建时间:2021-08-29T22:03:24
如何让玩家从一个NPC手中获得道具,并右键打开背包穿喵
明明噢world.onPlayerJoin(({ entity }) => { //玩家进入游戏时在这里初始化玩家的资产
entity.itemList = [] //口袋里的物品品
const npc = world.querySelector('#NPC');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 16; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为NPC名字,表示正在说话的是NPC
lookEye: entity, // 将相机放在玩家位置
lookTarget: npc, // 相机镜头对准NPC
content: `物品已加到你背包里`,
});
entity.itemList.push('防弹衣')//可自定义
});
至于接下来我不知道
点赞0
评论