时间线故事脚本_时间轴的创意脚本

时间线故事脚本

Timeline is a powerful tool for creating cutscenes and short movies. But there’s more to it! Let’s see how we can leverage Timeline to blend gameplay and storytelling, bringing our game to the next level.

时间轴是创建过场动画和短片的强大工具。 但是还有更多! 让我们看看如何利用时间轴将游戏玩法和故事叙述相结合,将我们的游戏提升到一个新的水平。

With the release of 2017.1, Unity added a new and powerful tool to its arsenal: Timeline. You have probably seen at this point how creators have leveraged Timeline to create incredible short movies, like Neil Blomkamp’s Adam Episode 2 and 3 or Unity’s own Book of the Dead, or to add storytelling to their games.

随着2017.1的发布,Unity在其工具库中添加了一个新的强大工具: Timeline 。 在这一点上,您可能已经看到创作者如何利用时间轴来制作令人难以置信的短片,例如尼尔·布隆坎普的《 亚当第二集和第三集》或Unity自己的《死者之书》 ,或者在他们的游戏中添加讲故事的内容。

This all sounds very exciting, but as a game developer, the question that I asked myself when I saw Timeline was: is it really just a linear sequencing tool? Can I only create cutscenes with it? Interrupt the gameplay, play a non-interactive sequence that advances the story, and resume gameplay?

所有这些听起来都非常令人兴奋,但是作为游戏开发人员,当我看到《时间轴》时我问自己的问题是:它真的只是线性排序工具吗? 我只能用它创建过场动画吗? 中断游戏,玩一个非互动序列来推进故事,然后恢复游戏?

With this question in mind, I created a small demo to use Timeline in a creative way. I made a little Real-Time Strategy game, in which I used some custom Timeline tracks to achieve a couple of interesting effects. And I found the answer to my question (spoiler): with a little bit of scripting, Timeline can do so much more.

考虑到这个问题,我创建了一个小示例,以创造性的方式使用时间轴。 我做了一个小小的实时策略游戏,在其中我使用了一些自定义的时间轴轨道来实现几个有趣的效果。 我找到了我的问题的答案(破坏者):只需编写少量脚本,Timeline就可以做更多的事情。

资产警报! (Assets alert!)

If you want to look into the demo that I created while you read, it can be downloaded here. I called it “A Terrible Kingdom” since it uses the graphic assets of “A Mighty Kingdom”, the demo used in the keynote for Vision Summit 2017. But I remixed them a little bit for the purpose of this demo.

如果您想看一下我在阅读时创建的演示,可以在 此处 下载 。 我将其称为“可怕的王国”,因为它使用了“强大的王国”的图形资产,这 是Vision Summit 2017主题演讲中 使用的演示 。 但是为了这个演示的目的,我对它们进行了一些混音。

想法1 –停止时间表 (Idea 1 – Stopping the Timeline)

Let’s start with a simple scenario. Let’s say I want the Timeline to incorporate a dialogue, and I want it to stop automatically to allow the viewer to read the text on screen. When the Spacebar is pressed, the Timeline resumes.

让我们从一个简单的场景开始。 假设我希望时间轴包含一个对话,并且我希望它自动停止以允许查看者阅读屏幕上的文本。 按下空格键后,时间轴将恢复。

Since this functionality goes hand in hand with the text on the screen, I created a custom track called Dialogue Track that hooks into the UI Manager of my game. Each clip has as properties the text to display, and a simple boolean to decide whether to stop or not. This is the Inspector of the clip:

由于此功能与屏幕上的文本紧密结合,因此我创建了一个名为 Dialogue Track 的自定义轨道 ,该 轨道 与我的游戏的UI Manager挂钩。 每个剪辑都具有要显示的文本作为属性,并具有一个简单的布尔值来决定是否停止。 这是剪辑的检查器:

Each clip on this track tells the UI Manager to display the dialogue UI, what text, and what size to use. Additionally, it can tell the GameManager to stop the Timeline and passes a reference to which one, so the GameManager – once Spacebar is pressed – knows which Timeline to resume. When the clip ends, it tells the UI Manager to hide the dialogue box.

该轨道上的每个剪辑都告诉UI Manager显示对话框UI,使用什么文本以及使用什么大小。 此外,它还可以告诉GameManager停止时间轴并传递一个参考,因此,一旦按下空格键,GameManager就知道要恢复哪个时间轴。 剪辑结束后,它告诉UI Manager隐藏对话框。

Pretty simple stuff, but it allows me to quickly build dialogues and decide when to stop, or not! (notice that the dialogue where Andy screams “Oi!” doesn’t stop, because it’s non-important text). Here’s how the Timeline looks like:

很简单的东西,但是它允许我快速建立对话并决定何时停止! (请注意,Andy尖叫“ Oi!”的对话不会停止,因为这是不重要的文本)。 时间轴如下所示:

想法2 –非线性时间表 (Idea 2 – Non-linear Timelines)

What if I want to rewind the Timeline? Not at the end (that would be easy: just set it to loop!) but at any arbitrary point, and only when a specific condition is verified. This basically allows for non-linear Timelines: sometimes they go back, sometimes they don’t. You can almost imagine them as if they contained an if-else statement.

如果我想倒退时间轴怎么办? 不是在最后(这很容易:只需将其设置为循环!),而是在任何任意点,并且只有在验证了特定条件时才可以。 基本上,这允许使用非线性时间轴:有时它们返回,有时却不这样做。 您几乎可以想象它们好像包含了if-else语句。

In this example, I have created a Timeline that animates a storm: the sunlight dims, flashes appear in the sky, lightning strikes hit the ground, and rain start falling down.

在此示例中,我创建了一个为风暴设置动画的时间轴:日光变暗,天空中闪烁,雷电击中地面,雨开始落下。

I didn’t just create the storm as one continuous sequence, but I envisioned it as three parts. At the beginning, there’s the “transition in”, while the end has a “transition out” to normal weather. In the middle, I left a section of the Timeline which will play during gameplay. Notice there are no Cinemachine clips, so Timeline gives control back to the regular gameplay camera.

我不仅将风暴作为一个连续的序列进行创建,而且将其分为三个部分。 一开始是“转入”,而结尾是“转出”到正常天气。 在中间,我留下了时间轴的一部分,该部分将在游戏过程中播放。 请注意,没有Cinemachine剪辑,因此时间轴将控制权交还给常规的游戏机摄像头。

I want the storm to go on as long as those two little monsters are alive. I want Timeline to play the intro, play the gameplay part, and just before hitting the outro, I want it to evaluate a condition: are those two little monster dead? If no, rewind the gameplay part and keep playing. If yes, just play the outro.

只要这两个小怪物还活着,我就希望风暴继续下去。 我希望时间轴播放简介,扮演游戏角色,并且在敲定结果之前,我希望它评估条件:那两个小怪物死了吗? 如果否,请倒退游戏部分并继续播放。 如果是,请播放小节。

Enter the Time Machine Track. Clips here can have two functions. One is to act as named markers (see the first clip), the other is to rewind or fast-forward the Timeline to a specific Marker or time. Let’s call this the “action” of the clip.

输入 Time Machine Track 。 这里的剪辑可以具有两个功能。 一种是充当命名标记(请参见第一个剪辑),另一种是将时间轴后退或快进到特定的标记或时间。 我们称其为剪辑的“动作”。

The other important property of the clips is the “condition”. It can be always, never (basically muting the clip), or if a group of units is dead. Notice how if the two monster are alive, the Timeline rewinds:

剪辑的另一个重要属性是“条件”。 它可以总是,从不(基本上使剪辑静音),或者如果一组单元已死。 请注意,如果两个怪物还活着,时间轴将倒带:

While if they are dead, it just goes on without interruption, playing the outro:

如果他们已经死了,它会继续播放而不会中断:

A note: This “is-dead” condition is very specific to my game, but you can come up with something new for your own specific needs, by plugging into the gameplay logic. Has the player reached a certain point? Has the player collected enough of a specific resource? The possibilities are endless!

注意: 这种“死定”状态是我的游戏所特有的,但是您可以通过插入游戏逻辑来提出满足自己特定需要的新内容。 玩家是否达到了某个点? 玩家是否收集了足够的特定资源? 可能性是无止境!

Now for the result:

现在来看结果:

The storm starts, then gameplay resumes and the storm goes on, rewinding a couple of times. As you can see, it’s a seamless rewind. Then, once the monsters are defeated – after a couple of seconds – the storm ends and gameplay resumes again.

风暴开始,然后游戏恢复,风暴继续进行,倒转了几次。 如您所见,这是无缝倒带。 然后,一旦击败怪物(几秒钟后),风暴结束,游戏玩法又恢复了。

理念3 –将时间轴插入游戏系统 (Idea 3 – Plugging Timeline into the game systems)

This is where things get exciting. Until now, we have put our animation on the Timeline. But what if we could defer this animation to some other system in our game? In my little RTS Demo, I have one very important system that’s active all the time: the game AI. This system is responsible of moving units around (by virtue of the NavMesh Agent), of controlling their Animator components and having the the units play the right animations at the right time: walking, idle, attack, or die.

这是令人兴奋的地方。 到目前为止,我们已经将动画 放在 时间轴上。 但是,如果我们可以将此动画推迟到游戏中的其他系统上怎么办? 在我的小型RTS演示中,我有一个一直很活跃的非常重要的系统:游戏AI。 该系统负责通过NavMesh Agent移动单元,控制其Animator组件并让单元在正确的时间播放正确的动画:行走,闲置,攻击或死亡。

So, say now I want to choreograph a big battle. I have two ways to do it: one is to create dozens of tracks, one for each unit, and then add hundreds of little animation clips: attack, move, attack, move again, attack again, and then die. All of these need to be adjusted in time, and some offset needs to be applied if I want them to match in space. All in all, it’s a lot of work.

所以,现在说我要编排一场艰巨的战斗。 我有两种方法:一种是创建数十条音轨,一个用于每个单元,然后添加数百个小动画剪辑:攻击,移动,攻击,再次移动,再次攻击然后死亡。 所有这些都需要及时调整,如果我希望它们在空间上匹配,则需要应用一些偏移。 总而言之,这是很多工作。

The other way is what I did with my AI Command track: this scripted track takes a special type in the binding, that I called “Platoon”. The Platoon is nothing else than a small script with an array of units. When you send a command to the Platoon script, it “broadcasts” the command to all of the units in its array. I actually use it for the selection in the game, creating a Platoon with the selected units to issue mouse commands.

另一种方式是我对AI Command轨道所做的事情:此脚本轨道在绑定中采用了一种特殊类型,我称之为“ Platoon”。 排只不过是一个小小的脚本,上面有多个单元。 当您向Platoon脚本发送命令时,它会将命令“广播”到其数组中的所有单元。 我实际上将它用于游戏中的选择,使用选定的单位创建了一个排以发出鼠标命令。

Back to the Timeline. By binding a Platoon to the AI Command track, I’m able to create clips that represent one command: move there and stand still, move there and guard, attack this specific unit, or even… die on the spot! When the Timeline is played, the units belonging to that Platoon will listen to these commands which will take precedence over whatever they were doing before, resulting in the ability to sequence commands on the AI on the Timeline.

返回时间轴。 通过将Platoon绑定到AI Command轨道,我可以创建代表一个命令的剪辑:移到那里并静止不动,移到那里并保卫,攻击这个特定单位,甚至……当场死亡! 播放时间轴时,属于该排的部队将收听这些命令,这些命令将优先于其之前所做的任何事情,从而可以在时间轴上的AI上对命令进行排序。

Add in a few camera shots (using Cinemachine, of course!), and you have a big battle with dozens of units using just 3-4 AI Command tracks:

添加一些镜头(当然,使用Cinemachine!),您将仅使用3-4条AI命令轨道就可以与数十个装置进行激烈的战斗:

Let’s see the result:

让我们看一下结果:

总结一下 (Summing it up)

I hope to have sparked your curiosity and creativity with this post. Next time you look at Timeline, think: what could I do with it? Create a Quick-Time-Event system? Orchestrate entire battles? Plan the bullet patterns in a Bullet Hell shooter? (I’m seriously thinking of doing it)

我希望通过这篇文章激发您的好奇心和创造力。 下次查看“时间轴”时,请思考:我该怎么办? 创建一个快速事件系统? 统筹整个战斗? 规划子弹地狱射击游戏中的子弹模式? (我正在认真考虑这样做)

There’s so much you can do with Timeline, a little creativity, and some scripting. I would personally love to hear what you come up with here in the comments or on Twitter. Get creating!

时间轴可以做很多事情,还有一点创造力和一些脚本。 我个人希望在评论中或 Twitter上 听到您提出的建议 。 开始创作!

翻译自: https://blogs.unity3d.com/2018/04/05/creative-scripting-for-timeline/

时间线故事脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值