查看: 2794|回复: 4
打印 上一主题 下一主题

使用unity3d+免费扩展工具开发2D游戏第一节

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2011-11-1 15:13:00 |只看该作者 |倒序浏览




           In this iDevBlogADay post, I’m going to kick off a new tutorial series that’s aimed at making a 2D sprite-based game in unity3d using only freely available tools, scripts and plugins. This isn’t the first 2D in Unity3D tutorial series I’ve done here – I previously did a 5 part series that used Sprite Manager 2 for the sprite display and animation duties. This time around, I want to show you how to make a game basically for free and I’m going to up the ante in this new series by adding in some other great plugins like iTween and A* Pathfinding.
         




            
         

           Over the course of this series, we’re going to recreate one of my all time favorite C64 games: Lode Runner! I always wanted remake Lode Runner for my own amusement but also as a way to try out some things I haven’t figured out how to do yet – like creating an AI that can follow the player on ladders.
         

           In this first installment, I’m going to introduce you to the tools we’ll be using and show you how to set them up in Unity. In the next part, we’ll dive in and start making the game. While we’ll be using the free versions of these tools, most of them also have paid options which unlock additional features.
         

           Tools:
           

           Unity3D: You probably already know that Unity3D is great tool for making 3D games, but it’s also pretty great at making 2D games with the addition of a few scripts and plugins. We’re going to be using the free version of Unity which will allow you to publish games to web as well as PC and Mac standalone but you can easily make the game work on iPhone or Android with a paid upgrade to those versions.
           

           Orthello 2D Framework: There are several different sprite plugins available for Unity, the most popular being Sprite Manager 2 which I have used extensively andwrote about in my earlier 2D game tutorial series. I recently found myself looking for an alternative to SM2 and while doing research, @jeedee mentioned that he was quite satisfied with Orthello so I thought I’d try it out. In some ways it’s not as easy to use as some of the other plugins out there – you have to make your own sprite atlases for example – but for a free plugin it offers a ton of great features and will work perfectly for our 2D project.
           

           iTween: iTween is my go-to animation system for every one of my projects here at Rocket 5. It’s ideal for animating everything from enemies to UI and it’s usually the first script I install when starting a new project.
           

           A* Pathfinding Project: A* Pathfinding is probably the most widely used pathfinding system available for Unity. It’s fast, powerful, easy to use and since there’s a free version it’s perfect for our project.
           

           TexturePacker: TexturePacker is a standalone app that makes it easy to create sprite sheets from your textures. You could use an image editing app like photoshop, Acorn or Gimp to make your atlases, but Orthello 2D recently added direct support for atlases generated by TexturePacker which should make things easier for us later on.
           

           Starting A New Project:
           

           Install the latest version of Unity and then create a new project by going to File -> New Project, click the Set… button and browse to a location on your drive where you want to save your Unity projects, enter a name for the project and then click Save. Optionally you can select any packages that you want to import into the new project, I didn’t import any packages into my new project. Finally click the Create Project button.
           

           Create a new folder in your Project view and name it “Scenes” and then save the current scene by going to File -> Save Scene As, open the Scenes folder you created in the previous step, name it “level1” and then click Save.
           

           Installing Orthello 2D:
           

           Open the Asset Store by going to Window -> Asset Store, search for “orthello2d“. The page for the plugin should display, click the Download button. Or download the latest version from the website, unzip the archive and double click onorthello.unitypackage.
           

           When the Import Package window appears, make sure that all the checkboxes are checked and then click Import. After a few seconds you should see an “Orthello” folder in your Project view.
           

           Orthello 2D Initial Setup:
           

           The Orthello website has tons of detailed information on setting up and working with the plugin so be sure to take a look. Following are my simplified steps to get you started.
         

           In order for Orthello to work in the scene, you’ll need to setup a few things first. Note that you will need to repeat these steps in every new scene you create.
         

           In the Unity Project view, go to Orthello -> Objects and then drag the OT prefab into either the Scene view or the Hierarchy.
           

           The OT prefab acts as a parent for Animations and Sprite Containers that we will be adding to the scene later on. Adding the OT object to your scene will also automatically make some changes to the Main Camara so that it will work properly for a 2D game – the main things are it changes the Projection to Orthographic and sets the Size to 332 (332 is kind of a weird size, but that’s the size that Orthello likes).
         

           Installing iTween:
           

           Open the Asset Store again by going to Window -> Asset Store, search for “itween“. The page for the plugin should display, click the Download button.
           

           When the Import Package window appears, make sure that all the checkboxes are checked and then click Import. After a few seconds you should see an “iTween” folder in your Project view. If you want you can delete the “ReadMe!” and “Sample” folders if you want but they won’t hurt anything and it’s a good idea to look at the sample scene if you’ve never used iTween before.
           

           Installing A* Pathfinding:
           

           As I write this, the free version of A* Pathfinding is not available for download from the Unity Asset Store (the paid version is though).
         

           Go to the website, click on Download Latest Version and then click on A* Pathfinding Project in the Download area which should download a file namedPathfindingProject
           


            _
           
           Free.unitypackage onto your computer.
           

           Double click on PathfindingProject
           
            _
           
           Free.unitypackage which will open theImporting Package window in Unity. Make sure all of the checkboxes are checked and then click Import. You should now see a folder named “AstarPathfindingProject” in your Project view.
           

           A* Pathfinding Initial Setup:
           

           Be sure to read the “getting started” page in the A* Pathfinding Documentation for a full explanation of how to setup A*. Here are my simplified steps to get you going.
         

           Create a new empty game object by going to GameObject -> Create Empty.
           

           Make sure that the x,y,z position of the game object is at zero and then rename the object to “A*“.
           

           Add the Astar Path script to the game object by going to Component -> Pathfindingand then click on Pathfinder.
           

           With the A* object selected in the Hierarchy, you should see Astar Path script’s options in the Inspector. At the top of the script you should see a message that says “Do you want to enable Javascript support?”. Since all of the scripts used in this tutorial are going to be written in C#, you can go ahead and click “No” (you can change this later in the settings if you want).
           

           Conclusion:
           

           If you followed all of the steps above, then your project should look something like this(click to see larger image).
         




           The cool thing about the project is that you can use this as a starting point for creating all kinds of 2D games so keep this around as a base for starting new 2D projects (although be sure to check for the latest versions of the scripts).
         
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

0

主题

0

听众

16

积分

设计初学者

Rank: 1

纳金币
16
精华
0
沙发
发表于 2012-7-5 11:34:34 |只看该作者
这个,鄙人英文水平极差啊,能不能搞点中文的啊
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

板凳
发表于 2012-10-30 23:24:24 |只看该作者
先垫一块,再说鸟
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

地板
发表于 2013-3-6 23:29:20 |只看该作者
不错 非常经典  实用
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2013-3-10 23:24:41 |只看该作者
加精、加亮滴铁子,尤其要多丁页丁页
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-21 07:50 , Processed in 0.106524 second(s), 35 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部