用户:
掩护我先走查看:0 回复:1 评论:0 创建时间:2021-09-21T15:06:34
我会做模型的互动,可是怎么做与玩家的互动?(靠近玩家后,弹出互动按钮,按E互动)
皮卡丘冫果汁(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
评论