游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

分享使用Unity制作游戏关卡的教程(1)

发布时间:2013-07-16 11:40:50 Tags:,,,,

作者:Matthias Zarzecki

我正在制作《Looking For Group – The Fork Of Truth》的关卡。

在本系列中,我们将使用Unity制作游戏的环境。第一部分主要介绍基本场景——地形。这是其他场景元素的构建基础。(请点击此处阅读本文第二部分

如果你已经看过我们的Kickstarter融资预告片,那么你应该看过这个场景了。

为了制作这些视频,我们其实制作了一个可玩的关卡。我们把它当作一个原型区域,用来测试战斗系统和游戏的世界观。我们将使用真正的Kickstarter视频,这样读者就可以预测到最终效果了。最终,这是要放进一个可玩的游戏中的(不过是比较短的游戏)。

关卡预览

角色从右下角的道路进入场景:

lower right(from gamasutra)

lower right(from gamasutra)

他们进入村庄,遭遇地精攻击:

goblin attack(from gamasutra)

goblin attack(from gamasutra)

再从农民(其实是一个地精扮的)处得到一个任务,追踪地精。他们被引入陷阱,在地精营地展开最后一战。

goblin camp(from gamasutra)

goblin camp(from gamasutra)

这个关卡的通关时间是10-20分钟,非常有趣。接下来我们来学习如何制作吧!

地形

整个关卡使用Unity Terrain来制作。这是一个制作自然场景的好办法。

首先打开Unity Terrain,即在菜单栏中选择”Terrain” -> “Create Terrain”。你会看到以下平面:

terrain_01(from gamaustra)

terrain_01(from gamaustra)

你可以使用不同的笔刷在这个平面上“画画”:

brushes and sizes(from gamasutra)

brushes and sizes(from gamasutra)

使用高度绘画工具(第一个模式),你可以画出高度差。简单地选择正确的模式,通过Unity viewport在平面上画出你的地形:

terrain_02(from gamasutra)

terrain_02(from gamasutra)

使用材质绘画工具,可以在地形上添加纹理。

apply textures(from gamasutra)

apply textures(from gamasutra)

使用草地等地面材质,如下图所示:

terrain_03(from gamasutra)

terrain_03(from gamasutra)

添加其他材质制作岩石、沙地等你所需要的地面类型:

terrain_04(from gamasutra)

terrain_04(from gamasutra)

道路很容易做。简单地画出某个高度,然后赋上材质就做好了:

terrain_05(from gamaustra)

terrain_05(from gamaustra)

以下是我们在《The Fork of Truth》中使用的材质:

the fork of truth(from gamasutra)

the fork of truth(from gamasutra)

使用这些简单的工具,你可以制作出复杂、逼真而有趣的地形。你可以看到右边的道路纹理,以及路面与水池形成的高度差。

Unity Terrain是强大的功能,提供多种选择和方式来制作游戏世界。你几乎可以用它制作出所有种类的景观。街道、河流、峡谷等——都能在简单的鼠标点击中完成。

垂直

但你得注意不要画蛇添足。你可以做出漂亮的地形,但丘陵地形可能成为你制作关卡的一大麻烦。

高度差使放置对象变成累人的杂事。可能到头来你得花上好几个小时调整场景中的对象的垂直位置,这样它们看起来才不至于浮在半空中或陷在地面上。

《The Fork of Truth》的地形基础是一个平面。上面仍然有丘陵和洼地,但这些纯粹是视觉上,你不可能接触到它们。在下图中,你可以看到有些非平面的区域。它们是不可进入的,因为有障碍物和“不可见的墙”。

hills_02(from gamasutra)

hills_02(from gamasutra)

保持关卡地形为平面的另一个好处是,更容易进攻。当地形不平时,进攻和技能释放会更加困难。召唤出来的龙卷风可以水平移动或者沿着道路移动吗?可以爬上悬崖吗?如果角色站在小山坡上,可以向下释放火球攻击敌人或让火球飞过敌人头顶吗?如果角色和敌人之间有一堵小坡挡差点呢?

保持关卡地开平坦可以有效地避免这些问题。像《暗黑》、《火炬之光》和《魔法对抗》等游戏也大量使用平原场景。因为这么做确实有充分的理由。

注意,即使我们让可行走的区域保持平面,我们也要让某些地方不平坦,以造成深度差的效果。为了拓展游戏,我们打算在关卡中加入高度。高度差和悬崖使关卡设计更加有趣,所以我们不想错过。

depth(from gamasutra)

depth(from gamasutra)

水体

在《The Fork Of Truth》中,角色目前还无法与水体互动。如果有什么东西掉进水里的话,比如在攻击时地精被打进水里,那么它就会立即被消灭。

关卡中的河流是地形上的洼地,低于平地30个单位。从下图中你可以看到河流的“峡谷”,里面还有一些装饰性的物品。只要添加水体就成为河流了。

lfg_water(from gamasutra)

lfg_water(from gamasutra)

水面有几种不同的选择。最简单的一种是用蓝色透明的平面方形做成的:

lfg_water(from gamasutra)

lfg_water(from gamasutra)

Unity有若干水体着色器。以下是基本的一种。它有水波动画和简单的反射,但不透明:

lfg_water(from gamasutra)

lfg_water(from gamasutra)

以下这一种更高级一些(现在颜色有一点不正常)——有上图中的水波动画,也是透明的。

lfg_water(from gamasutra)

lfg_water(from gamasutra)

另一种堪称完美(游戏邦注:在Unity Pro中叫作“Water4”)。它是透明的,能形成倒影,有水波动画,非常适合这款游戏的卡通风格。它在边界处还有一个有趣的特点。即使它有诸多优点,但并不像其他高级水体类型那么需要高帧率。

lfg_water_04(from gamasutra)

lfg_water(from gamasutra)

总结

在Unity中,关卡构建的过程始于总体的地形布局。以下我总结成三点:

1、使用Unity Terrain快速雕刻地形和贴材质。

2、保持可行走道路平坦,使关卡设计更容易。

3、Unity有若干种水体着色器,我们使用的是Pro着色器的“Water4”。

运行除了有地面和水体,其他基本空白的关卡仍然能让人感到满足。如果是,那么你就已经为接下来的关卡制作做好准备了。

预告:本文接下来一部分我们将介绍如何在关卡中放置对象,以及用树、灌木、栅栏等小物品装饰场景。(本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦

Building Levels in Unity – Part 1 of 3

by Matthias Zarzecki

Hi! I’m Matthias Zarzecki, and I’m making the levels Looking For Group – The Fork Of Truth (among other things).

In this series we’re going to use Unity to create a game environment. The first part will deal with the basic landscape – the terrain on which the rest of the environment is built.

If you’ve seen our rockin’ trailer or our Kickstarter video, you can see the environment the characters fight in.

To make these videos, we set out to actually built a playable level. It serves as a prototyping area, to test the combat system and overall look-and-feel of the game. We wanted to use actual footage for the Kickstarter videos, so people would know what to expect. Ultimately this resulted in a fully functional game (albeit a rather short one).

Level overview

The gang starts in the lower right:

They break into a village and get in the way of a goblin attack:

Then they get a quest from a farmer (actually a goblin in disguise), and track down the goblin menace. They are lured into a trap, resulting in the final battle in the goblin camp:

The level takes about 10-20 minutes to play through, and is quite fun. So let’s talk about how we made this!

Terrain

The entire level uses the Unity Terrain. It is a great way to create natural landscapes.

To get started with Unity Terrain, select “Terrain” -> “Create Terrain” in the menu bar. You start with a flat plane:

Unity Terrain lets you “paint” on this surface, using different brushes and sizes:

Using the Height painting tool (the first mode), you can paint height differences. Simply select the right mode, and paint your terrain on the plane in the Unity viewport:

Using the texture painting tool, it is possible to apply textures to the terrain:

Start with a base texture like grass or dirt, and take it from there:

Add extra textures to create rocks, sand, any type of ground you need:

Roads are easy to create. Simply paint a specific height, and assign a road texture to the terrain:

These are the textures we used for The Fork of Truth:

With these simple tools, you can create complex terrains that are convincing and interesting to look at. You can see the road texture painted on the right, and the height differences in the pool:

Unity Terrain is an awesome feature, and offers a wide array of options and ways to create a world. You can sculpt almost any kind of landscape with it. Create streets, rivers, canyons – all with a swipe of the mouse.

Verticality

But you have to be careful not to overdo it. Things may look great, but a hilly terrain could give you all kinds of level design headaches.

Height differences make placing things a chore. You might end up spending hours adjusting the vertical position of the objects in the scene, so that they don’t float in the air or are stuck in the ground.

The basis for the LFG-game is a flat plane. There are still hills and depressions, but these are purely visual. You can’t actually reach them. You can see some of these non-flat areas highlighted in the picture below. They are inaccessible due to obstacles and invisible walls:

Another benefit of keeping your level flat is simpler attacks. Attacks and abilities become much more complicated when there is an uneven terrain. Does a summoned tornado move horizontally, or does it move along with the floor? If so, could it move up a cliff? If you are standing on a hill, does your fireball hit the enemies below or do they fly over? What about if there is a hill between you and the enemy?

Keeping the level “flat” gently sidesteps these problems. Games like Diablo, Torchlight and Magicka use a mostly planar environment as well. And with good reason.

Note that even though we kept the walkable areas flat, we did add uneven ground in some places to give the impression of depth. For the extended game we plan on using height in the levels. Height-differences and cliffs make for interesting level design, so we don’t want to leave it out for the real thing.

Water

The characters can’t interact with water in The Fork Of Truth (yet). Should anything fall into the water anyway, like a goblin thrown by an attack, it is killed immediately.

The river in the level is a depression in the terrain, moving down to 30 units below the “floor-level”. Here you can see the river “canyon”, with some decorative objects placed within. All it needs is a bit of water:

There are different options for the water surface. The simplest version is a simple flat square with a  blue color and transparency:

Unity comes with several water shaders. This is the basic one. It has animated waves and simple reflection, but no transparency:

This one is a more advanced version (the coloring is a bit off at the moment). It is transparent, and has all of the wave-animations of the previous one:

The next one is just about perfect (it is called “Water4″ in Unity Pro). It is transparent, reflects the environment, has animated waves, and nicely fits the cartoony visuals of the game. It also has an interesting “fizzle” area at the borders. Even though it has all of this great stuff, it doesn’t kill the framerate like some of the other advanced water types.

Conclusion

The level building process in Unity starts with the general terrain layout. Here is a summary of the tips:

Use the Unity Terrain for fast landscape sculpting and texturing

Keep the walkable paths flat for easier level design

Unity has several great water shaders, we used the Pro shader “Water4″

Running around in an essentially empty level with just the ground and water beneath your feet can still be satisfying. If that is indeed the case, you have built a solid foundation for the rest of the level.

Next time: We’ll have a look at placing the objects in the level, and fill up the environment with trees, bushes, fences, and other doodads.(source:gamasutra)


上一篇:

下一篇: