用户:张允旭查看:3 回复:6 评论:3 创建时间:2021-12-05T11:41:49
代码如下:
//岛三进阶教程:玩家互动
world.onPlayerJoin(({ entity }) => {
entity.enableInteract = true //允许互动
entity.interactRadius = 5 //互动范围
entity.interactHint = `与${entity.player.name}互动` //提示的文字
entity.player.showName = false //隐藏玩家的名字(不然会很奇怪)
})
world.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: `与${targetEntity.player.name}互动`,
lookTarget: targetEntity,
content: `请选择互动方式`,
options: ['对话', '取消'],
});
if (result.index === 0) {
const result1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: `请输入对话内容`,
lookTarget: entity,
content: `请输入对话内容`,
});
if (result1 != null) {
targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: `${entity.player.name}`,
lookTarget: entity,
content: result1,
});
}
}
})
如果想看B站视频请看评论区
sppX教喵++imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E8%B0%A2%E8%B0%A2%E8%80%81%E6%9D%BF.gif"alt="emotion_编程猫_谢谢老板"
点赞0
评论