未登录,请登录后再发表信息
最新评论 (0)
播放视频

Unity 5 官方教程 #4 - 设置游戏区域

Unity 5 - Roll a Ball game - 4 of 8: Setting up the Play Area - Unity Official Tutorials

So let’s set up our play field.
现在我们来设置游戏区域
The play field for our game will be very simple.
我们的游戏界面很简单
We will place walls around the edges to keep our player game object from falling off,
我们会在平面上放置墙体 避免球体跌出
and we will create and place a set of collectable objects for our player to pick up.
然后放置一系列可采集的对象 让玩家收集
First let’s create a new game object,
首先我们新建一个游戏对象
and rename it “Walls”.
重命名为”Walls”
This will be an organizing parent game object for our Wall objects.
它将是所有墙体对象的父对象
Let’s look at the organization of our Hierarchy.
让我们来看看层级面板的结构
Organization in our projects and our Hierarchy are very important.
项目结构及层级关系十分重要
We need to understand that organization at a glance.
我们得理解其内部组织结构
We organize our projects using folders or directories
我们用操作系统生成的文件夹或者目录
created by our operating system.
来组织我们的项目
We add these to our project using the Project view’s Create menu.
我们用项目视图的Create菜单来新建它们
We organize our Hierarchies by using GameObjects.
我们用游戏对象来组织层级关系
In our Scene, GameObjects can hold other GameObjects.
在场景中 一个游戏对象可以包含另一个
Don’t be afraid to use an empty GameObject as a directory or folder in the Hierarchy.
不要害怕用空游戏对象 当做层级面板目录或者文件夹
Reset this GameObject to origin,
将游戏对象重置为初始状态
and this step is important.
这一步非常重要
We want the Transforms of all of our container GameObjects to be at origin before we use them.
在使用之前 所有的游戏对象的Transforms状态要置为坐标原点
Now we will build our walls.
现在我们构造墙体
Let’s start by creating a new Cube to be our first wall.
让我们新建立方体 使之变为我们的第一面墙
Rename this “West Wall”.
重命名为”West Wall”
Reset this game object to origin.
将它重置到原点
Now parent West Wall to our Wall’s game object.
现在West Wall是Walls的子对象
Let’s focus our Scene view camera to our Wall object.
让场景摄像机的焦点对准墙体对象
We can do this by typing the F key
我们可以把光标置于场景界面
while the cursor is over the Scene view,
并按下F键
or by selecting Edit > Frame Selected.
或者点击Edit工具栏下的Frame Selected
We need to change the size of the Cube to fit one side of our play area.
我们需要改变立方体的尺寸 让它适应游戏场地的边缘
Change the Cube’s Transform Scale of X, Y and Z
改变方体Transform组件中Scale的X Y及Z大小
to 0.5 for thin, 2 for tall, and 20.5 for long.
分别为0.5作为厚度 2为高度以及20.5作为长度
Now we can simply push the wall into place using the Translate tool,
现在我们使用Translate工具将墙体移至边缘
or we could enter a value into the Transform component.
或者我们在Transform组件的Position中输入值
In this case we can set the Transform’s position X value to -10.
在这里我们将X的值改为-10
This places the wall neatly to the edge of our play area.
这就将墙体放置在了场地的边缘
To create the next wall we could start with another new Cube,
再用新的立方体新建一面墙
but then we’d have to rescale this new Cube before we placed it.
但是这样做我们就得像之前一样设置参数
Our current West Wall is already the perfect size.
我们现有的墙体已经达到了完美的大小
So let’s duplicate the West Wall game object.
所以我们复制一下West Wall游戏对象
Let’s rename it “East Wall”.
重命名为”East Wall”
To place the wall simply remove the negative sign,
要放置它只需简单去掉负号即可
and it pops into place on the east side of our game area.
然后它就会出现在东边的位置
Now let’s duplicate the East wall…
现在我们复制East Wall
and call it “North Wall”.
重命名为”North Wall”
Reset the X position so the North Wall is in the center of the play area.
将其Position的X重置 它就出现在了场地的中心
We now have two choices:
我们现在有两个选择:
We can rotate the wall by 90 degrees,
我们可以将墙体旋转90度
or, as this is a cuboid,
或者 既然它是立方体
we can rescale the wall to 20.5 in the X and 0.5 in the Z.
我们将Scale的X重置为20.5 将Z重置为0.5
Now it’s scaled correctly for its orientation as the “North Wall”.
现在”North Wall”的方向正确了
We can drag the wall into place,
我们将其拖动到北面
or we can simply use the value of 10 in the Transform’s Position Z field to place it.
或者我们也可以将Transform组件中Position的Z 设置为10
Duplicate North Wall and call it “South Wall”,
将其复制并重命名为”South Wall”
and -10 in the Z-axis pops it into place.
将其Position的Z设为-10使其出现在合适的位置
Enter Play mode and test.
然后进入游戏模式进行测试
Fantastic, the walls work fine.
很棒 墙体起了作用
Remember to test early and test often, don’t wait to test.
记住要尽早并经常测试 不要等到最后
Let’s exit Play mode.
现在退出玩家模式
Let’s highlight the Player GameObject
选中Player游戏对象
and set the Editor to Local mode,
然后将编辑器设置为Local模式
and try again.
再试一次
Note how in Local mode we can see the Transform rotate.
注意观察在Local模式中 Transform的值如何变化
Let’s exit Play mode.
现在退出测试
In the next episode we will be creating our collectable pickup objects.
下个教程中我们将创建可被收集的物体

发表评论

译制信息
视频概述

如何设置滚球小游戏的游戏区域呢?来看看吧

听录译者

Germanotta

翻译译者

审核员

审核员1024

视频来源

https://www.youtube.com/watch?v=dahT0wRVO1Q

相关推荐