用户:
中國萬歲_青铁迷查看:20 回复:2 评论:20 创建时间:2022-08-08T10:22:23
如题,这是一个检测有没有买票并开启闸机的动画代码
const elevator = world.querySelector('#闸机的门-2')
elevator.fixed = true
elevator.collides = true
const lo = [38, 27.3, 76.9]
const hi = [36.6, 27, 76.9]
const anissss = elevator.animate([
{ position: lo, duration: 1 },
{ position: lo, duration: 3 },
{ position: hi, duration: 1 },
{ position: hi, duration: 3 },
], {
duration: 16 * 2,
iterations: 0,
direction: Box3AnimationDirection.WRAP,
})
anissss.onReady(() => {
world.say('开启成功')
})
anissss.onFinish(() => {
world.say('')
})
world.querySelectorAll('#闸机-1').forEach((npcs) => {
npcs.enableInteract = true
npcs.interactRadius = 2;
npcs.interactHint = '闸机';
npcs.onInteract(async ({ entity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `${entity.player.name},请问你要`,
title: '自动售票机',
options: ['通过', '通你/妈过'],
})
if (result.value == '通过') {
if (entity.sjjak == 1) {
anissss.play({
duration: 16 * 15,
iterations: 1,
direction: Box3AnimationDirection.WRAP,
})
}else{
world.say(`${entity.player.name} 你还没买票去买票去`)
}
}
})
})
有没有人可以把它改成按下E键后,打开离着玩家最近的那个闸机,而不是只打开一个,求求了awa

无极玄天互动=>遍历实体=>如果是闸门=>将a设为此闸门到该玩家的距离,并加个标签‘闸门aaa’=>如果下一个闸门的a小于此a=>将a替换,并将原闸门的标签“闸门aaa”去掉,给这个闸门加上‘闸门aaa’=>全部遍历完后再遍历一次=>如果此实体有标签‘闸门aaa’=>此实体运行动画
点赞0
评论