用户:
论名字怎么取查看:0 回复:5 评论:0 创建时间:2021-06-05T22:08:25
那位大佬知道怎么与玩家互动?
岛三吗?
world.onPlayerJoin(({ entity }) => {//有玩家进入地图时
entity.player.showName = false //为有更好的效果,隐藏玩家的名字(否则会很奇怪)
entity.enableInteract = true //允许实体互动
entity.interactRadius = 5 //互动范围
entity.interactHint = `和 "${entity.player.name}" 互动` //可以互动时显示的文字
})
world.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "系统",
lookEye: entity,
lookTarget: targetEntity,
content: `向" ${targetEntity.player.name} "互动`,
options: ['对话', '取消'],
});
if (result.index === 0) {
const result1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "系统",
lookTarget: entity,
content: `请输入对话内容`,
confirmText: "发出对话"
});
if (result1 != null) {
targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: entity.player.name,
content: result1,
});
}
}
});点赞0
评论