Unity Creator Kit: Puzzle

Creator Kit: Puzzle 资源地址

✅ Get Started with the Creator Kit: Puzzle

新建Unity项目3D | 版本选择 2022.3 或更高 | 导入Creator Kit: Puzzle资源 | 双击 ExampleMenu :

image.png

点play 按钮运行起来:

image.png

✅ 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:

image.png

点击 Create Menu,就会在这个路径下生成一个新的名为 newMenu 的Scene:

image.png

双击 newMenu 打开场景 | 选中MenuCanvas | 找到它身上的 Scene Menu 脚本:

image.png

设置第一关。
点击Create and Add 按钮 create a new level。

image.png

This will create a default level linked to the menu, which you can customize.

image.png
  • Give your level a name in the Display Name field.
  • Total Required Stars : When players complete a level, they earn stars which will allow 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 of 0.
  • Finally, select times for the three Star Time fields in seconds. The faster players complete a level, the more stars they should receive: your Three Star Time should have the lowest value, and One Star Time the highest.

最后,为三个“Star Time”字段选择时间(以秒为单位)。玩家完成关卡的速度越快,他们应该获得的星星就越多:你的Three Star Time 应该具有最低值,One Star Time 应该具有最高值。

➡️ Open the Layout Editing System

在 Project窗口下,双击刚刚创建的 newLevel 场景:

image.png

select the LevelLayout GameObject | find the PuzzleLayout component

image.png

This will enable you to choose puzzle pieces to use in your level and snap them together.
这将使您能够选择要在关卡中使用的puzzle pieces并将它们组合在一起。

Click the Editing Layout button:

image.png
  1. Click the StraightRampPieces box button. This will show all the straight ramp pieces available to you. 这将显示所有可用的【直坡道】。
  2. 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.

image.png

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:

image.png
  • Turn the puzzle piece from left to right using the x-axis button
  • Turn the puzzle piece back to front using the z-axis button
  • Flip the puzzle piece upside down using the y-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的开头对齐,请拖动这些箭头以移动它。

image.png

select the Goal GameObject

Repeat the process to center the view on the Goal, and move it to the end of your puzzle.

image.png

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 拖拽到场景中:

image.png

选中 Spoon 游戏对象,找到它下面的脚本组件:Flipper。

  • 这个 Interact Key 字段作用是指定交互按键:当玩家按下一个键时,所有 InteractivePuzzlePieces 都会被激活。默认是空格键,可以点击下拉菜单更改。

  • Find the Power slider. This controls the power of the puzzle piece in the game. This has been set to a sensible 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.

image.png

➡️ Create Another 【Marble】

You can also add multiple marbles to your levels to create more imaginative puzzles. 您还可以在关卡中添加多个弹珠,以创建更具想象力的谜题。

找到 Assets/Creator Kit - Puzzle/Prefabs/OnePerLevel

image.png

可以在拖拽1个 Marble到场景中,命名为 Marble2:

image.png

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.
image.png
  • 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 of your new marble from the drop-down menu.
image.png

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 see its child GameObjects. Select the Timing GameObject.
image.png
  • find the Timing Recording script component. Click the circular button to the right of the Starting Marble field and select the name of your new marble.
image.png

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 of your new marble from the drop-down menu.
  • Save your changes.
image.png

➡️ 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 select Duplicate
  • 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.
image.png
  • Save your changes.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,126评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,254评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,445评论 0 341
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,185评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,178评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,970评论 1 284
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,276评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,927评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,400评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,883评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,997评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,646评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,213评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,204评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,423评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,423评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,722评论 2 345

推荐阅读更多精彩内容