没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
44页
用C#开发unity游戏的实例, Below you'll find a detailed explanation from which you can make the beginning of a game very similar to EVAC-CITY, a 2D top down survival alien shooter myself and Daniel Wilkinson developed and which is currently free to play here: Click to play EVAC-CITY
资源推荐
资源详情
资源评论
EVAC-CITY
A starters guide to making a game like EVAC-CITY
Index
Introduction................................................................................................................................................3
Programming - Character Movement.........................................................................................................4
Programming - Character Animation.......................................................................................................13
Programming - Enemy AI........................................................................................................................18
Programming - Projectiles.......................................................................................................................22
Programming - Particle Effects and Damage...........................................................................................27
Programming - Additional Development.................................................................................................36
Level Design - Object Placement.............................................................................................................39
Level Design - Game Design...................................................................................................................44
Download tutorial resources
Download the Example Projects
Play EVAC-CITY
By David Lancaster
http://www.youtube.com/Daveriser
Page 1 of 44
Introduction
Hello and welcome to this tutorial. Below you'll find a detailed explanation from which you can make
the beginning of a game very similar to EVAC-CITY, a 2D top down survival alien shooter myself and
Daniel Wilkinson developed and which is currently free to play here:
Click to play EVAC-CITY
This tutorial will introduce you to the programming language C# of Unity 3D, Level Design in Unity
3D, and how to create textures and art assets in The Gimp.
This tutorial is best done when you have a familiar understanding of the Unity 3D interface. Learning
Unity 3D's interface is very intuitive and easy. `The game engine is free to download and use for a
period of 30 days, and the Indie license of the game is currently $199.00 USD (at the time I wrote this
tutorial, price may have changed since then).
You can download the free version here:
http://unity3d.com/unity/download
Here are some very intuitive video tutorials which will get you comfortable with the Unity 3D
interface:
http://unity3d.com/support/documentation/video/
Thank you for taking the time to look through this tutorial and I only hope it helps you abundantly in
your desire to become a skillful game developer.
Let's start with programming character movement!
David Lancaster
http://www.youtube.com/Daveriser
Page 2 of 44
Character Movement
Programming Tutorial Part 1
First things first, we need a character which moves around! Create an empty Unity 3D game project
that imports none of the unity packages which comes with the software.
Open Unity > Goto > File > New Project > Name it 'EVAC-CITY tutorial'.
If you don't have it already go ahead and download the free resources needed for this tutorial here:
Download tutorial resources
Download the Example Projects
Then Open up the Unity project you have just created goto the assets folder and drag the Tutorial
Resouces folder you had downloaded and drag it into the assets folder.
Once this is done you can now save the scene Goto > File > Save Scene As...
Scene.
Firstly I'm going to create an empty game object and name it 'Player', to rename an object left click
over the name of the object in your Hierarchy and keep your mouse stationary over the object after
releasing left click for a second.. Then from the menu with your new game object selected, choose
(component – mesh – mesh filter), and (component – mesh – mesh renderer). In the mesh filter I am
going to select 'plane' which is made available from adding the above .fbx file to your assets folder.
Also, select 'plane' from your project window, in the inspector look at the FBX importer component, set
the scale factor to 1 and click apply.
Now we need a material to render our character onto the plane! You might have noticed that when you
import an fbx file it automatically creates a material for you. I'm just going to delete what it creates
and create my own and name it 'PlayerMaterial'. Right click the project window and create a new
material. Select the PlayerSpriteSheet.png that you downloaded above and use it as a texture for your
new material. Select (transparent-diffuse) as the shader for your material.
Now in your player object's mesh renderer, select your PlayerMaterial in the materials tab. You should
now see what is displayed in the image on the next page:
Page 3 of 44
Okay our player is being rendered onto our plane! Now let's make sure he's tiled correctly. Select your
PlayerMaterial and set your X tiling to -0.2 and your Y tiling to -0.25. We are going to animate our
character by changing the tiling of the character dynamically over time! I set the Y tiling to -0.25 for
mathematical reasons, in the next tutorial we shall cover animation and if this is not set to a negative
value the animation wont run properly because of the way I have set up calculating which animation to
play. And set the X tiling to -0.2, I have no idea why it's a negative value I must have had a reason a
while ago when I wrote the animation code but the code likes it to be that way and I'm going to trust it.
Next add to your player (component – physics – rigidbody) and (component – physics – capsule
collider) the capsule collider adds a collision object to our player, this collision object will collide with
other collision objects in our world. The rigidbody gives our player a physics based movement to our
capsule collider, this is allows our collider to move around, push and interact with other objects in our
game world.
Make sure you turn off the use gravity check box in your rigidbody component otherwise your player is
going to keep on falling forever.
It's time now to script our character to move around. But first I should let you know, if you are new to
programming more than likely you're only going to understand bits and pieces of code at a time, to
understand it all at once takes experience, don't fret if you go ahead and implement the code in this
tutorial without understanding it all. Understanding comes over time with experience and it's normal
not to understand things.
Page 4 of 44
Right click in your project window and select (create – C Sharp Script) call your script 'AIscript', now
it's completely up to you how you organise your project window (we spell organize with an S in
Australia). In the future I wont tell you where to put the things you create in this tutorial but leave it up
to you to put things where you think they belong best. In this case I created a folder called 'scripts' and
put my C Sharp Script in there. The reason I am calling this script 'AIscript' instead of say
'PlayerScript' is that this script is going to be designed in such a way that both the enemies and player
will use the same script. You could create separate scripts but I personally like to keep things local.
Now open your AIscript and firstly and always change the name of class to the name of the script
otherwise Unity wont compile it.
using UnityEngine;
using System.Collections;
public class AIscript : MonoBehaviour {
Any code highlighted blue in this tutorial is code that wont change, anything highlighted red is the code
I am indicating for you to change. If the code is simply a green color, it is completely new code with
no code which is preexisting.
Leave the Start and Update functions as they are, the Start function is called only once at the beginning
of the object's life which is using the script, and Update is called once every frame while the object is
alive.
Let's create a new function called FindInput(); This function will find the input which needs to be sent
to the remaining functions to determine what the character will do. This input is either going to be
player controlled or AI controlled. I am also going to add 2 more functions below FindInput, one will
be used for finding the player's input and the other for AI input.
Add this below the Update function:
void FindInput ()
{
if (thisIsPlayer == true)
{
FindPlayerInput();
} else {
FindAIinput();
}
}
void FindPlayerInput ()
{
}
void FindAIinput ()
{
}
Page 5 of 44
剩余43页未读,继续阅读
资源评论
agileheart
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于springboot+layui的医院日常耗材管理系统.zip
- 计算机毕业设计-ASP.NET教育报表管理系统-权限管理模块(源代码+)-毕设源码实例.zip
- 计算机毕业设计-ASP.NET教务信息管理系统的设计与实现(源代码+)-毕设源码实例.zip
- Eleven的精益供应链管理-碓胤咨询龚胤全.rar
- 5套光伏、储能、充电收益测算表.zip
- C2 供应链集成演示平台操作手册(详细版).rar
- 3套光储充一体化站CAD+PDF图纸.zip
- Screenshot_20240426_195831_com.huawei.android.launcher.jpg
- 2000-2023年各省专利侵权结案数据.xlsx
- C#使用NPOI操作合并单元格
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功