unity 程序员技能_向非程序员教授Unity:Unity Playground

unity 程序员技能_向非程序员教授Unity:Unity Playground_第1张图片

unity 程序员技能

Many teachers around the world struggle with delivering introductory workshops on making games. Tools like Unity are complex pieces of software and offer a wide range of possibilities. However, the Unity editor also assumes that the students know many concepts that are hard to deliver in just a few lessons.

世界各地的许多老师都在努力举办有关制作游戏的入门讲习班。 诸如Unity之类的工具是复杂的软件,提供了广泛的可能性。 但是,Unity编辑器还假设学生知道许多概念,仅在几节课中很难讲授这些概念。

One of my first “missions” as Technical Evangelist at Unity was to present a 2-day workshop to absolute game development beginners in a town near Brighton. The attendees didn’t know Unity before, but had received some lessons in basic programming. As such, the easiest way to introduce them to Unity would be a step-by-step tutorial. But after the first day I decided that this approach wouldn’t allow them to express the creativity I saw they had right away. So on the train back I started working on a small framework that would allow them to build a variety of games, fast, and without necessarily knowing about programming.

我在Unity担任技术布道者的第一个“任务”之一是在布莱顿附近的一个小镇为绝对游戏开发初学者提供为期2天的研讨会。 与会者以前并不了解Unity,但是已经接受了一些基础编程方面的课程。 因此,将它们引入Unity的最简单方法是分步教程。 但是在第一天之后,我决定这种方法将不允许他们表达我立即看到的创造力。 因此,在火车上,我开始研究一个小型框架,该框架使他们可以快速构建各种游戏,而不必了解编程。

The “Unity Playground” was born.

“ Unity Playground ”诞生了。

需求和解决方案 (Needs and solutions)

When I set off to create the framework, I had a few goals in mind. First, I wanted to teach people that making games can be fun. I wanted to give them the full game creation experience, but at the same time trying not to overwhelm them with the technical concerns that come with it. Most importantly, I didn’t want to constrain their creativity.

当我开始创建框架时,我想到了一些目标。 首先,我想教人们制作游戏会很有趣。 我想为他们提供 完整的游戏创作体验 ,但同时又尽量不要让他们随之而来的技术顾虑。 最重要的是,我不想限制他们的创造力。

I also decided it would be cool to allow them to play with the parameters of the game, to allow some sort of game tuning and playtesting (game designers, yes!).

我还决定让他们玩游戏的参数,进行某种 游戏调整 和游戏测试(游戏设计师,是的!) 是很酷的 。

Another key goal was to minimise my intervention as teacher, since I quickly discovered that handling a group of 25 alone was impossible. The framework would need to prevent as many mistakes as possible, and guide the students.

另一个主要目标是 最大程度地减少我 作为老师的 干预 ,因为我很快发现单独处理25人一组是不可能的。 该框架将需要防止尽可能多的错误,并指导学生。

So I came up with a small framework that revolves around a few cornerstones around which I make every decision:

因此,我想出了一个小型框架,该框架围绕着我做出每个决定的几个基石:

  • A set of one-task Components that are easy to use and mix

    一组易于使用和混合的单任务组件

  • Extremely simple scene setup

    极其简单的场景设置

  • Physics-based gameplay = more fun!

    基于物理的游戏玩法=更有趣!

  • 2D for simplicity (other graphics can be imported from the web)

    2D为简单起见(其他图形可从Web导入)

  • Custom Inspectors to perform error detection in the setup

    定制检查器在设置中执行错误检测

  • Pre-made UI to visualise health and score

    预制的UI可以直观显示健康状况和得分

Going into more detail, the Components are all simple scripts that perform mostly one task, so they can be mixed to produce more refined gameplay. For instance, you can use together the scripts RotateWithArrows and PushWithButton to create a character that rotates with the Left/Right keys and move forward with the Up key, such as a spaceship or a car seen from above.

更详细地讲,组件都是执行大部分任务的简单脚本,因此可以将它们混合在一起以产生更精致的游戏玩法。 例如,可以将脚本 RotateWithArrows 和 PushWithButton 一起使用 来创建一个字符,该字符可以使用向左/向右键旋转, 并 可以使用 向上键向前移动,例如太空船或从上方看的汽车。

Their inspectors are heavily customised with the help of Editor code and provide plenty of guidance in setting up. This component for example shows some tips at the bottom, and will hide the option Look axis if the Orient to direction boolean is unselected.

他们的检查员在编辑器代码的帮助下进行了大量自定义,并在设置方面提供了大量指导。 例如,此组件在底部显示一些提示,并且 如果 未选中“ 定向到方向” 布尔值 ,则将隐藏“ 查找轴 ”选项 。

unity 程序员技能_向非程序员教授Unity:Unity Playground_第2张图片

用户界面 (User Interface)

Talking about the UI, I made it a prefab that can be dropped into the scene without any setup. It will accommodate different kinds of gameplay, and will change depending if the game is for one or two players. This is its Inspector:

谈到UI,我把它做成了一个预制件,无需任何设置就可以放到场景中。 它会适应不同类型的游戏玩法,并且会根据游戏是针对一个还是两个玩家而变化。 这是它的检查器:

unity 程序员技能_向非程序员教授Unity:Unity Playground_第3张图片

And this is how it looks in-game:

这就是游戏中的样子:

play3

Additionally, it will automatically display a small inventory in the bottom-left corner for games that have objects that can be picked up. In this example, the player has 0 coins and 1 key:

此外,对于具有可拾取对象的游戏,它会自动在左下角显示少量库存。 在此示例中,玩家有0个硬币和1个钥匙:

unity 程序员技能_向非程序员教授Unity:Unity Playground_第4张图片

条件,动作,属性 (Conditions, Actions, Attributes)

After the first iteration proposed in the original workshop, I tried to give some structure to the Playground, so I came up with some key groups of scripts that try to serve specific classes of problems.

在最初的工作坊中提出第一轮迭代之后,我尝试为Playground提供一些结构,因此我提出了一些关键的脚本组,试图解决特定类别的问题。

At the heart of the framework are the Conditions, which are basically if statements made components. They check for a specific condition and, if this is verified, execute some actions. The Condition scripts available for now are Area Conditions (basically triggers, enter, exit, and stay), the Collision Condition (fires on collision), and a configurable Key Condition to capture input. More may be added in the future.

该框架的核心是 Condition ,基本上是 如果语句 构成组件的条件。 他们检查特定条件,如果经过验证,则执行一些操作。 现在可用的条件脚本是 区域条件 (基本上是触发器,进入,退出和停留), 碰撞条件 (碰撞时触发)和可配置的 关键条件, 用于捕获输入。 将来可能会添加更多。

In the first iteration, I grouped the actions under an UnityEvent. Despite its power though, the UnityEvent block in the Inspector is huge and complicated to setup, because it exposes ALL the public properties and methods of the target objects:

在第一个迭代中,我将动作归为一个UnityEvent。 尽管具有检查功能,但Inspector中的UnityEvent块仍然庞大且设置复杂,因为它公开了目标对象的所有公共属性和方法:

play5

So, I decided to implement a series of mini-scripts that contain one action. Conditions now have a simplified block (made with the useful ReorderableList, check it out on Valentin’s blog!) where you can connect them easily by drag-and-drop. I grouped these scripts under the name Gameplay Actions, and they all implement the IGameplayAction interface.

因此,我决定实施一系列包含一个动作的微型脚本。 现在,条件有了一个简化的块(使用有用的ReorderableList制成,请在 Valentin的博客 上查看 !),您可以通过拖放轻松地将它们连接起来。 我将这些脚本归类为 Gameplay Actions ,它们都实现了 IGameplayAction 接口。

Following this simplification, a ConditionKeyPress Inspector with the Gameplay Actions block looks like this:

经过这种简化,带有Gameplay Actions块的ConditionKeyPress Inspector如下所示:

unity 程序员技能_向非程序员教授Unity:Unity Playground_第5张图片

The bool Use custom actions reveals another UnityEvent block to allow the most fearless students to get the full power of UnityEvents and access any variable or method.

使用自定义动作 的布尔值 显示了另一个UnityEvent块,以使最无所畏惧的学生获得UnityEvents的全部功能并访问任何变量或方法。

Finally, some scripts are grouped under Attributes, as they effectively work as if they were mere properties of an object. For instance, adding a Resource Attribute to an gameObject makes it an object that can be picked up and stacked, shown in the UI as an icon or amount, and later on consumed by a ConsumeResource GameplayAction script.

最后,一些脚本被归类为 Attributes ,因为它们有效地工作,就好像它们只是对象的属性一样。 例如,将 资源 属性 添加 到gameObject使其成为可以拾取和堆叠的对象,在UI中以图标或金额显示,然后由 ConsumeResource GameplayAction脚本使用。

游戏范例 (Example games)

The Scenes folder contains some example games, intended to showcase the variety of gameplay that can be achieved with the framework.

文件夹中包含一些示例游戏 幕后 ,旨在向人们展示了各种可与框架来实现的游戏。

The Defender game shows how to shoot objects (the laser) or generate them randomly (the asteroids), and is also an example of a life-based game where the player’s health script is not on the character gameObject, but on a part of the environment.

后卫 游戏节目如何拍摄对象(激光)或随机生成它们(小行星),也是一个基于生活的游戏,玩家的生命剧本上没有的字符游戏对象的例子,但在的一部分环境。

unity 程序员技能_向非程序员教授Unity:Unity Playground_第6张图片
Football game is a 2-player football game that shows how to use ConditionCollision scripts to setup goals, and reset players and ball position when the players score a goal. 足球 比赛是一个2玩家的足球游戏,展示了如何使用ConditionCollision脚本设置目标,并重置球员和球的位置,当队员进球。
unity 程序员技能_向非程序员教授Unity:Unity Playground_第7张图片

The Maze game shows the use of Collectables (for the coins), how to setup Area Conditions, and load another level through the LoadLevelAction.

迷宫 游戏节目使用藏饰的(对硬币的),如何建立区域条件,并加载通过另一个层面 LoadLevelAction 。

unity 程序员技能_向非程序员教授Unity:Unity Playground_第8张图片

The Lander game showcases an atypical setup for collisions, where only collisions with certain parts of the spacecraft will make it explode.

各州 游戏陈列柜非典型设置了碰撞,其中只有航天器的某些部分的碰撞将使它爆炸。

unity 程序员技能_向非程序员教授Unity:Unity Playground_第9张图片

Finally, the Roguelike game shows how to create a small “crafting” system with Conditions and ConsumeResource actions. The merchant asks for three coins (which have a Resource script), and once you collect them, he will give the player a key (another Resource) which can be picked up to open the door.

最后, Roguelike 游戏展示了如何使用Conditions和ConsumeResource动作创建一个小的“制作”系统。 商家要求提供三个硬币(带有“资源”脚本),一旦您将它们收集起来,他便会给玩家一个钥匙(另一个“资源”),您可以将其拿起以打开门。

unity 程序员技能_向非程序员教授Unity:Unity Playground_第10张图片

I suggest to remove the example games before distributing the framework, so that users won’t see them. We said this framework was made to make their imagination go wild, right?

我建议在分发框架之前删除示例游戏,以免用户看到它们。 我们说这个框架是为了让他们的想象力变得疯狂,对吧?

尝试框架! (Try the framework!)

Together with the rest of the evangelism team at Unity we have decided to release the Playground on Github. You can clone the repository, modify it in any way, and use it in your workshops.

我们与Unity的其他布道团队一起决定 在Github上 发布Playground 。 您可以克隆存储库,以任何方式对其进行修改,然后在您的工作室中使用它。

I’m still working on the framework, trying to balance the addition of new scripts and possibilities while still keeping the whole thing accessible and understandable (for both the beginners, but also for teachers!), while keeping the documentation up to date with the changes.

我仍在研究框架,尝试在增加新脚本和可能性之间取得平衡,同时仍使整个内容易于访问和理解(对于初学者而言,对于老师也是如此!),同时使文档与变化。

Keep in mind that the project is maintained only by me, so for suggestions, doubts or (hopefully not) bugs you can ping me on Twitter.

请记住,该项目仅由我维护,因此对于建议,疑问或(希望不是)错误,您可以 在Twitter上 ping我 。

翻译自: https://blogs.unity3d.com/2016/09/20/teaching-unity-to-non-programmers-playground-project/

unity 程序员技能

你可能感兴趣的:(游戏,java,python,编程语言,人工智能)