用户:
忠诚的呆鲤鱼JSog查看:2 回复:3 评论:2 创建时间:2022-01-24T13:46:00
如果无效的话,就取消
entity.enableInteract=true; entity.onInteract(({...})=>{ ... }) Forexample: /*在场景中搜索名称为NPC的模型,允许和它进行互动*/ constnpc=world.querySelector('#NPC'); npc.enableInteract=true;//开启实体互动功能 npc.interactHint='NPC';//进入互动范围时提示的文字 npc.interactRadius=32;//互动范围大小 //场景中所有可以互动的实体,互动时都会触发此事件 world.onInteract(({entity,targetEntity})=>{ targetEntity.say('你好!'+entity.player.name); }); docs: docs.box3.cod喵/box3world.html#input-点击互动 docs.box3.cod喵/box3entity.html#互动
点赞0
评论
entity.enableInteract=true;
//entity不是关键字,必须要在world.onPlayerjoin(({...})=>{...})这样的语句中通过{entity, ...}才能得到。
entity.onInteract(({ ... }) => {
... //在这里放你的代码实现互动
})
点赞0
评论