用户:
PlumSteven查看:4 回复:6 评论:4 创建时间:2021-08-13T11:04:10
const npc = world.querySelector('#NPC'); npc.enableInteract = true; // 允许进行互动 <=
这行报错了 npc.interactRadius = 16; // 实体的互动范围 npc.interactHint = npc.id; // 互动提示框显示实体的名称 npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色 这段代码是示例代码,我复制过来就报错了(第2行),谁知道解决方法?
![]()
余谦望/* 在场景中搜索名称为 NPC 的模型,允许和它进行互动 */ c喵t npc = world.querySelector('#NPC'); npc.enableInteract = true; // 开启实体互动功能 npc.interactHint = '文字'; // 进入互动范围时提示的文字 npc.interactRadius = 32; // 互动范围大小
// 场景中所有可以互动的实体,互动时都会触发此事件 world.onInteract( ({entity, targetEntity}) => { targetEntity.say('你好! ' + entity.player.name+'!'); targetEntity.say('文字文字文字'); targetEntity.say('文字文字文字'); targetEntity.say('文字文字文字'); });
点赞1
评论
七式草莓const npc = world.querySelector('#NPC');
if(npc){
npc.enableInteract = true; // 允许进行互动 <= 这行报错了
npc.interactRadius = 16; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色
}点赞0
评论