unity {0:d2}_Unity培训摘要:2D功能和提示

unity {0:d2}

In recent versions of Unity, some incredible 2D tools have been added. Now that we’ve reached a critical mass of 2D features, it feels like a good time to look back over some of our most popular 2D content and put them all in one place in case you have missed anything.

在最新版本的Unity中,添加了一些不可思议的2D工具。 现在我们已经达到了关键的2D功能,现在是时候回顾一些我们最受欢迎的2D内容并将它们全部放在一个地方,以防万一您遗漏任何东西。

After watching these videos you’ll be able to use Unity’s 2D toolset to rapidly design beautiful 2D worlds, create custom 2D physics in C#, use our powerful new sorting tools, and much more.

观看完这些视频后,您将能够使用Unity的2D工具集快速设计漂亮的2D世界,在C#中创建自定义2D物理,使用我们强大的新排序工具等等。

In case you’ve never followed along with one of our Live Sessions, each of these video playlists contains an hour long video presentation, as well as free project assets including scripts, scenes and artwork, which you can use to follow along and learn about Unity’s features, or just grab and re-use in your own projects!

如果您从来没有关注过我们的现场直播,则每个视频播放列表都包含一个小时的视频演示,以及免费的项目资产,包括脚本,场景和艺术品,您可以用来跟踪和了解Unity的功能,或者只是在您自己的项目中使用并重用!

Live Sessions happen on Wednesday nights GMT and people who show up for the live event are able to ask questions during the session, and stay for an extended Q&A at the end, which is usually a lot of fun. If you’ve never attended one live, we’d love to see you there! You can find the full schedule here.

现场会议在格林尼治标准时间星期三晚上举行,参加现场活动的人可以在会议期间提出问题,并在会议结束后留下延长的问答时间,这通常很有趣。 如果您从未参加过现场演出,我们很乐意在那见到您! 您可以在此处找到完整的时间表。

使用2D游戏工具进行设计 (Designing with 2D game tools)

The first session we’ll look at is Designing With 2D Game Tools. The focus of this session was to show some of the powerful new sorting and collision tools, which were recently added to Unity. The sorting tools are particularly useful for developers who are making games in which there is any kind of forced perspective. In this case, game elements need to be able to move in front of or behind one another.

我们将讨论的第一部分是2D游戏工具设计。 本次会议的重点是展示一些功能强大的新排序和碰撞工具,这些工具最近已添加到Unity中。 排序工具对于制作具有任何强制视角的游戏的开发人员特别有用。 在这种情况下,游戏元素必须能够彼此前后移动。

Unity already includes functionality called Sorting Layers, which allows you to define which layer is rendered in front of another, and also a more fine tuned order in layer option to define sorting within a single layer. For situations in which there is no dynamic sorting of sprites this is fine, but if we want one object to be able to move closer to the camera and then sort in front of other objects it poses a challenge.

Unity已经包含了称为“排序图层”的功能,该功能使您可以定义在另一个图层之前呈现的图层,还可以使用更精细的图层顺序选项来定义单个图层内的排序。 对于没有对精灵进行动态排序的情况,这很好,但是如果我们希望一个对象能够移近相机,然后在其他对象之前进行排序,则会带来挑战。

The addition of the capability to define Axis Sorting and Sorting Groups made solving these problems much, much easier. Axis Sorting is simple, but very useful. It allows you to define an axis, which as an object moves along it will cause it to sort in front of or behind other objects.

定义轴排序和排序组的功能的添加使解决这些问题变得非常容易。 轴排序很简单,但是非常有用。 它允许您定义一个轴,当对象沿该轴移动时,它将导致其在其他对象之前或之后排序。

In our video demo we used the Y axis, so objects at the bottom of the 2D screen are drawn in front of objects which are higher up on the screen. This feature combines very well with Sorting Groups. Sorting Groups allow us to group together a set of objects based on their Transform hierarchy and render them together. This means that, for example, all parts of a character that are children of the same GameObject will be sorted as one object.This avoids situations like, for example, when the head of a character is behind a tree, but the leg is in front (which looks very, very weird).

在我们的视频演示中,我们使用了Y轴,因此2D屏幕底部的对象绘制在屏幕上方较高位置的对象前面。 此功能与排序组很好地结合在一起。 排序组使我们可以根据其变换层次结构将一组对象组合在一起,并将它们呈现在一起。 这意味着,例如,属于同一GameObject的子代的角色的所有部分都将被排序为一个对象,从而避免了诸如当角色的头部在树后面但腿在其中的情况前面(看起来非常非常奇怪)。

In the session below we’ll work through sorting groups, and also look at some of the powerful new 2D collider options, including the new dynamic Composite Collider 2D.

在下面的会话中,我们将研究排序组,并研究一些强大的新2D对撞机选项,包括新的动态Composite Collider 2D。

演示地址

使用Tilemap和Cinemachine的2D世界建筑 (2D World building with Tilemap & Cinemachine)

Our second session is 2D World building with Tilemap & Cinemachine for 2D. In this session we continue to use Composite Collider 2D, but in this case in combination with Unity’s Tilemap. Tilemap is an incredible tool for 2D games that allows you to rapidly author levels on a Grid by drawing sprites and collision data with brushes. In this training we design a small 2D platformer level using Tilemap and add collision to the tiles using the Tilemap Collider.

我们的第二场会议是使用Tilemap和Cinemachine进行2D的2D世界建筑。 在本次会议中,我们将继续使用Composite Collider 2D,但在这种情况下,将其与Unity的Tilemap结合使用。 Tilemap是2D游戏不可思议的工具,它允许您通过使用画笔绘制精灵和碰撞数据来快速在Grid上创建关卡。 在本培训中,我们使用Tilemap设计一个小的2D平台游戏者级别,并使用Tilemap Collider将碰撞添加到图块。

The Tilemap Collider adds collision to the sprites in the Tilemap based on their shape. The drawback with using it on its own is that a Collider is added to every single tile on the Grid, including tiles which nothing will ever collide with, because they’re in the middle of a wall for example. Adding the Composite Collider 2D allows us to significantly optimize this by combining all those colliders together, leaving only the relevant collision shapes, and a much smaller number of total colliders in the scene.

Tilemap Collider根据其形状将碰撞添加到Tilemap中的精灵。 单独使用它的缺点是在网格上的每个单个图块上都添加了对撞机,其中包括不会发生碰撞的图块,例如,它们位于墙的中间。 添加Composite Collider 2D可以使我们将所有这些对撞机组合在一起,从而只剩下相关的碰撞形状,并且场景中的总对撞机数量要少得多,从而可以显着优化此效果。

One of the most interesting new aspects of building worlds with Tilemap is the fact that Tiles themselves are scriptable, and during the training we will walk through a series of awesome dynamic tile tools including animated tiles, random tiles and context-aware rule tiles, which change their sprite based on what they are next to. All these tools are available separately as part of the 2D Extras Pack on GitHub, and already included in the free project which you can download to follow along with the 2D Worldbuilding session.

使用Tilemap构建世界的最有趣的新方面之一是,Tiles本身是可编写脚本的事实,在培训期间,我们将逐步介绍一系列令人敬畏的动态切片工具,包括动画切片,随机切片和上下文感知规则切片,根据他们旁边的东西来改变他们的精灵。 所有这些工具都可以作为GitHub上2D Extras Pack的一部分单独提供,并且已经包含在免费项目中,您可以下载该项目以跟随2D Worldbuilding会话。

In addition to looking at building levels with Tilemap, we also introduce Cinemachine for 2D. Cinemachine is an incredible new camera solution from Unity, which removes the pain of writing complex camera code. Cinemachine makes designing subtle, dynamic camera systems easier than ever.

除了使用Tilemap查看建筑物级别外,我们还介绍了用于2D的Cinemachine。 Cinemachine是Unity令人难以置信的新相机解决方案,它消除了编写复杂相机代码的麻烦。 Cinemachine使设计微妙的动态摄像机系统比以往更加容易。

Previously, the tool was only available for 3D projects, but now we’ve updated it to include 2D support as well. In this example we’ll create a dynamic camera, which smoothly follows our character while never allowing the player to see outside of the pre-defined background area.

以前,该工具仅适用于3D项目,但现在我们对其进行了更新,以包括2D支持。 在此示例中,我们将创建一个动态摄像机,该摄像机可以平滑地跟随我们的角色,同时绝不允许玩家看到预定义背景区域之外的内容。

演示地址

For a short, 3 minute video, which just looks at Cinemachine, check out our dedicated feature demo video as well.

观看3分钟的简短视频(仅看Cinemachine),也请查看我们的专用功能演示视频。

演示地址

2D Platformer角色控制器 (2D Platformer Character Controller)

The third session is a more advanced, programmer oriented session. This session is called 2D Platformer Character Controller. In this session we go through the process of writing a character movement script, or controller for a 2D platformer character. Unity includes a 2D physics system called Box2D which seeks to provide, for lack of a better term ‘realistic’ physics.

第三部分是面向程序员的更高级的部分。 该会话称为2D Platformer角色控制器。 在本节中,我们将讨论编写角色移动脚本或2D平台游戏角色的控制器的过程。 Unity包含一个称为Box2D的2D物理系统,该系统试图提供一个更好的术语“现实”物理。

Objects have inertia, gravity, friction and can bounce off each other and slide around. The canonical 2D platformer games that we know and love, like for example the Mario series by Nintendo do not use realistic physics. Instead they have custom, hand-written movement and physics code which is designed specifically for the gameplay of those games. This is what we and our players have been trained over the years to feel is ‘right’ in platformer games.

物体具有惯性,重力,摩擦力,并且可以相互反弹并滑动。 我们知道和喜爱的经典2D平台游戏,例如Nintendo的Mario系列,都没有使用现实的物理学。 取而代之的是,它们具有专门为这些游戏的玩法而设计的自定义手写运动和物理代码。 这就是我们和我们的玩家经过多年的训练,认为在平台游戏中是“正确的”。

That doesn’t mean this is the only way to ever make a platformer, by all means feel free to break the mold and reinvent the wheel, but if you’ve ever tried to make a good feeling platformer controller using physics and struggled with that, this probably has something to do with it.

这并不意味着这是制造平台游戏的唯一方法,请务必随意破坏模具并重新发明轮子,但是如果您曾经尝试使用物理方法制作具有良好感觉的平台游戏控制器,并为此付出了很多努力,这可能与它有关。

The approach shown here hooks into Unity’s collision and overlap detection system to manage collision with the environment, but none of the actual movement of the character is handled by the 2D physics system. This allows programmers a much greater degree of control over how their movement feels, and in my opinion should come closer to a ‘classic’ 2D platformer feel.

此处显示的方法与Unity的碰撞和重叠检测系统挂钩,以管理与环境的碰撞,但是2D物理系统无法处理角色的实际移动。 这使程序员可以更好地控制他们的运动感觉,我认为应该更接近“经典” 2D平台游戏的感觉。

演示地址

We hope you’ve found some of this information useful for your own 2D projects and would love hear about your experiences working with our 2D tools.

我们希望您发现其中一些信息对您自己的2D项目有用,并希望听到您使用我们的2D工具的经验。

Have you used any of these tools? Did you like them? Let me know in the comments below.

您是否使用过这些工具中的任何一个? 你喜欢他们吗? 在下面的评论中让我知道。

翻译自: https://blogs.unity3d.com/2018/01/13/unity-training-roundup-2d-features-tips/

unity {0:d2}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值