✅ Get Started with the Creator Kit: Puzzle
新建Unity项目3D | 版本选择 2022.3
或更高 | 导入Creator Kit: Puzzle资源 | 双击 ExampleMenu
:
点play 按钮运行起来:
✅ Design a Simple Puzzle
In this Creator Kit, you’ll use connectable puzzle pieces
to build tracks which are used to guide a marble to a goal. In this tutorial, you’ll:
- Set up a new game
- Design a
ramp
system for your puzzle - Test your first level
您将使用可连接的拼图来构建轨道,用于引导弹珠到达目标。
- 为您的拼图设计一个坡道系统
How to Use the 【Menu
】 and 【Level System
】
➡️ Create a Menu: 顶部菜单 Puzzle Kit Tools > Create Menu:
点击 Create Menu,就会在这个路径下生成一个新的名为 newMenu
的Scene:
双击 newMenu 打开场景 | 选中MenuCanvas | 找到它身上的 Scene Menu 脚本:
设置第一关。
点击Create and Add
按钮 create a new level。
This will create a default level linked to the menu, which you can customize
.
- Give your level a name in the Display Name field.
- Total Required Stars : When players
complete a level
, they earn stars which willallow them to move on to a new one
(if this is available). Since players have no stars when they begin, this first level should have a requirement value of0
. - Finally, select times for the three Star Time fields
in seconds
. The faster players complete a level, the more stars they should receive: yourThree Star Time
should have the lowest value, andOne Star Time
the highest.
最后,为三个“Star Time”字段选择时间(以秒为单位
)。玩家完成关卡的速度越快,他们应该获得的星星就越多:你的Three Star Time
应该具有最低值,One Star Time
应该具有最高值。
➡️ Open the Layout Editing System
在 Project窗口下,双击刚刚创建的 newLevel 场景:
select the LevelLayout
GameObject | find the PuzzleLayout
component
This will enable you to choose puzzle pieces
to use in your level and snap them together
.
这将使您能够选择要在关卡中使用的puzzle pieces
并将它们组合在一起。
Click the Editing Layout
button:
- Click the
StraightRampPieces
box button. This will show all the straight ramp pieces available to you. 这将显示所有可用的【直坡道】。 - Select the
sloping straight piece
— starting with a slope will help get the marble rolling. 选择倾斜的笔直部分——从斜坡开始将有助于使弹珠滚动。
marble
n. 大理石
(用玻璃、泥等制成的)弹子
弹子游戏
Click in the Scene view to add the piece
as a child of the LevelLayout
GameObject.
When you’ve finished
adding ramp pieces, click the Editing Layout
button again to turn off editing mode
. Remember to save your changes! 记得退出编辑模式
As you add more puzzle pieces
, especially curved ramps
, you may want to change the orientation of a piece
. You can use the Flip field
buttons to:
- Turn the puzzle piece
from left to right
using thex-axis
button - Turn the puzzle piece
back to front
using thez-axis
button - Flip the puzzle piece
upside down
using they-axis
button
You can also press 【R
】 to change the connector the piece will use to snap to the next one.
➡️ Position the Marble and Goal
select the Marble
GameObject.
If the Marble GameObject is not properly aligned to the start of the puzzle, drag on these arrows to move it.
如果 Marble 游戏对象未正确与puzzle的开头对齐,请拖动这些箭头以移动它。
select the Goal GameObject
Repeat the process to center the view on the Goal, and move it to the end of your puzzle.
Now you can test the puzzle — click Play
in the toolbar to begin. If you get stuck, you can restart the level by pressing the R
key.
现在您可以测试puzzle了 —— 在工具栏中点击“播放”开始游戏。如果您卡住
了,可以通过按下R键来重新开始该关卡。
✅ Increase the Challenge
In this tutorial, you’ll:
- Add more objects to your puzzle
- Add more marbles to your puzzle
➡️ Add More 【Prefab Objects】
到 Assets/Creator Kit - Puzzle/Prefabs/PuzzlePieces
下找到 InteractivePuzzlePieces
,把它下面的 Spoon
拖拽到场景中:
选中 Spoon 游戏对象,找到它下面的脚本组件:Flipper。
这个 Interact Key 字段作用是
指定交互按键
:当玩家按下一个键时,所有 InteractivePuzzlePieces 都会被激活。默认是空格键
,可以点击下拉菜单更改。Find the
Power slider
. This controls the power of thepuzzle piece
in the game. This has been set to asensible default
, but you can customize this for your puzzle. 控制了游戏中puzzle的力量。这已被设置为合理的默认值,但您可以为您的puzzle自定义它。
You can add as many InteractivePuzzlePieces
to your level as you like.
You can also add OtherPuzzlePieces
using the same drag and drop process. These pieces don’t need any input from the player
.
➡️ Create Another 【Marble】
You can also add multiple marbles
to your levels to create more imaginative puzzles
. 您还可以在关卡中添加多个弹珠,以创建更具想象力的谜题。
找到 Assets/Creator Kit - Puzzle/Prefabs/OnePerLevel
:
可以在拖拽1个 Marble到场景中,命名为 Marble2:
To make sure that the Camera can follow different marbles
in your level:
- select the
TargetGroup
GameObject - find the
Cinemachine Target Group
component for the GameObject.
- Go to the
Target list
at the bottom of the component and click the+
button. Then click the circular button to the right of the new item on the list and select the name ofyour new marble
from the drop-down menu.
Save your changes.
➡️ Start the Level with a Different Marble
When you click Play, the initial marble in the level is frozen in space until the level has finished fading in
, at which point the timer starts. If you want your new marble to be the one that starts the game, you need to adjust the Timing
GameObject
单击“播放”时,关卡中的初始弹珠将冻结在空间中,直到关卡完成淡入,此时计时器将启动。如果希望新弹珠成为游戏的启动对象,则需要调整 Timing 游戏对象:
- click the arrow to the left of the
LevelUICanvas
GameObject to seeits child
GameObjects. Select theTiming
GameObject.
- find the
Timing Recording script
component. Click the circular button to the right of theStarting Marble field
and select the name ofyour new marble
.
TIP: You can also use the Timing Recording component
to change the key used to 【restart the game
】, by selecting a new key in the Reset Key Code
field. 可以修改重新启动游戏的Key
➡️ Finish the Level with a Different Marble
If you want your new marble to be the one that triggers level completion
, you also need to change the Goal settings
:
- select the
Goal GameObject
. - find the
Target Trigger component
- Click the circular button to the right of the
Marble field
and select the name ofyour new marble
from the drop-down menu. - Save your changes.
➡️ Add Multiple Puzzle Layouts to your Level
If you want to really create a challenge
, you can also add multiple puzzles
to one level. This can be useful if you want to play with 【more advanced designs
】. 更高级的设计
Note: As you’ve previously explored, only assigned marbles can start or end the level
. If you are using multiple puzzle layouts
in one level, check carefully to make sure you have assigned these roles correctly
or you may have difficulty playing the level.
正如您之前所探索的,只有指定的弹珠才能开始或结束关卡
。如果您在一个关卡中使用多个puzzle布局
,请仔细检查以确保您正确分配了这些角色,否则您可能难以玩该关卡。
To add multiple puzzle layouts to your level:
- select the
LevelLayout GameObject
-
Right-click
on LevelLayout and selectDuplicate
- Right-click on LevelLayout (1) and select Rename; give the new GameObject a
more memorable name
. - go to the
PuzzleLayout component
. You will be able to use this to build you ramp, just as you did for your first layout.
- Save your changes.