猫史档案馆


【box3】谁知道如何让玩家和实体互动,发下代码。(发代码的送赞和收。)

用户:忠诚的呆鲤鱼JSog忠诚的呆鲤鱼JSog查看:2 回复:3 评论:2 创建时间:2022-01-24T13:46:00


如果无效的话,就取消


回复

上一页1 页 / 共 1下一页
小苏打_小苏打_

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


评论


小苏打_小苏打_

可以发下地图链接吗

emotion_doge

点赞0


评论