用户:
小王子WYS查看:3 回复:3 评论:3 创建时间:2022-01-23T20:35:26
如果我已经将NPC条贴好,为什么我按E否显示不出来对话框,只能发世界消息或个人消息? //NPC是non-playercharacter的简称,表示游戏里无人控制的虚构人物 for(constnpcofworld.querySelectorAll('.NPC')){ npc.enableInteract=true//允许当前npc实体触发交互 npc.interactRadius=4.5//交互范围 npc.interactHint=npc.id//交互提示文本显示实体名字 npc.interactColor.set(0,1,0)//交互提示文本颜色为绿色 if(npc.id=='学生'){//如果实体名是'学生' npc.onInteract(async({entity})=>{//当玩家对这个npc按E触发交互,npc对玩家打招呼 textDialog(entity,`${entity.player.name},你好呀~`,npc.id) }) } }
皮卡丘冫果汁(XCL)// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('#NPC');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 4.5; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(0,1,0); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为NPC名字,表示正在说话的是NPC
content: `你好,${entity.player.name},很高兴认识你
});
});点赞0
评论
皮卡丘冫果汁(XCL)// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('#NPC');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 8; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(0,1,0); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为NPC名字,表示正在说话的是NPC
content: `你好,${entity.player.name},很高兴认识你`,
});
});点赞0
评论