用户:
Henry_嘟查看:2 回复:2 评论:2 创建时间:2022-08-25T18:08:49
求助,怎么在box3写点击实体就可以和它互动的程序,急!
艾博士// 先在场景中放置一个名称为 的实体。
const npc = world.querySelector('#名字-1');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 6; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为 名字,表示正在说话的是
lookEye: entity, // 将相机放在玩家位置
lookTarget: npc, // 相机镜头对准
content: `${entity.player.name},拿走不谢`,
});
});点赞0
评论