Unity 3D 做FPS游戏

2023-11-02

Part 1: Introduction 第一部分 介绍


This tutorial will detail how to make a simple First Person Shooter (FPS). It will introduce fundamental 3D game programming concepts and give tips on how to think like a game programmer.
这个教程将详细介绍如何制作一个简单的第一人称射击(FPS)游戏,它将介绍基本的3D游戏程序概念并且给出一个游戏程序员如何进行思考的提示

Setting up the game environment 安装游戏环境

下载FPS_Tutorial这个例题~里面的资源就都有了。原来英文教程上的废话很多,不过确实很贴心,大家就慢慢看吧。红色的字是我自己写的。


Once the assets have been imported, you’ll notice there are many folders in the Project panel.
一旦资源被导入,你将注意到项目面板上有许多目录


 In the Projects panel, Select the mainLevelMesh from Objects/mainLevelMesh/mainLevelMesh.


在项目面板上,从Objects/mainLevelMesh/mainLevelMesh中选择mainLevelMesh


 In the Inspector panel, inside of the FBXImporter options you’ll find the "Generate
Colliders" option. Toggle that option on. If we don’t do this, the player will
simply fall through the level (no collision).
在检查面板上,有一个FBXImporter选项,你将找到“产生碰撞器”选项,勾选它,如果我们不这样做,游戏者落下时将穿过层面
 Drag the mainLevelMesh into the scene.
拖拽mainLevelMesh到场景中
 

 

我参考的那个网上的翻译文档真的很要命啊!!翻译了那么多的错误。有兴趣的可以百度一下对比看看。

There is no need to add a light to the scene, the level is already fully lightmapped. The
imported level uses lightmaps for all lighting which allows us to use prebaked shadows.
这里不需要给场景增加灯光,这个层面上已经提供了充分的光影,这个导入层使用了允许我们使用prebaked Shadows预焙阴影。
Lightmaps are very good for performance, especially if you want to create a
complex lighting setup.
光照图用起来非常好,尤其是你想建立一个复杂的灯光设置的时候
You’re now ready to add a character into the environment.
你现在准备要给环境中增加一个角色
Adding the Main Character 增加主角

We’re now going to add in a character for the player to control. Unity has a built in
prefab specifically for a firstperson controller. This can be found in the Project panel under Standard Assets>Prefabs.
 To add the First Person Controller, click on the arrow beside Standard Assets in the Project panel, as list of assets will appear. Find the folder called Prefabs and click on the arrow in the left hand side. You should now see the First person controller asset. Drag this into the Scene view.
~~

在新的3.4版本里面已经没有这个第一人称控制器了已经不在这个地方了~~,所以也就不用看英文了,

我是先去创建一个Box~~然后拖拽摄像机到这个box上,成为子物体,然后给Box加上碰撞检测。(实际情况是,我发现这个盒子控制起来真是要命,真相是一个人套在盒子里...)

You should see a cylinder object representing the player, 3 large arrows for altering
the location in 3D space for the object (if you do not see 3 arrows then
press the‘W’key), and a white mesh which shows the object’s viewport (where
it is currently looking). The FPS Controller is now the default camera, by moving
this object, you change the current view in the Game View. You’ll also notice
that the FPS Controller has a camera icon on top of it. Move the character so
that it is above ground level in the environment.

 

今天早上我重新打开了这个项目,发现导入Character Controllers插件包里面是有这个First Person Controller的!~直接拖出来就可以用了。

 

第二部分是武器,没有什么新资源了,下来时需要写代码了。

This intermediate-level tutorial extends upon the Basic FPS tutorial by introducing game elements such as multiple weapons, damage and enemies.
Prerequisites
This tutorial assumes that you are familiar with the Unity interface and basic scripting
concepts. Additionally, you should already be familiar with the concepts discussed in
Part 1 of the FPS tutorial series.
Before we begin -level setup
Download FPS_Tutorial.zip, unzip, and open the project folder in Unity. If you
have completed Part 1, then unzip the files to a new folder.
Import the Standard Assets Unity Package.
Add the mainLevelMesh and FPS controller prefab to the scene.
NOTE In this tutorial no new scripts need to created. We’ll be using the ones that
were downloaded from the Unity Package.
Weapon switching Before we discuss how to create each individual weapon, we need to write some code to manage how the weapons are initialized and switched from one to another. Let’s look at the Javascript for PlayerWeapons.js:

首先是给武器一个位置,我们建立一个空物体,作用是定位子弹从什么地方发射出去。这个难度不大,有一个Unity 3D做坦克大战的教程里面已经写好了如何发射炮弹。

(很抱歉,这个博客没有隐藏功能,写了半截只能放在这里了)

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Unity 3D 做FPS游戏 的相关文章

随机推荐

  • python数字信号_Python数字信号处理应用

    第 1章 声音和信号1 1 1 周期信号1 1 2 频谱分析3 1 3 信号4 1 4 波形的读写6 1 5 频谱7 1 6 波形对象7 1 7 信号对象8 第 1章 声音和信号1 1 1 周期信号1 1 2 频谱分析3 1 3 信号4 1
  • 电脑大小写怎么切换_快速练习好电脑打字的方法

    使用电脑的基本技能 打字 很多人打字都是二指禅 极其不专业 让人看了感觉到非常的搞笑 当有专业的人看见你二指禅打字 就会感觉你这个人水平不行 根本不会盲打 要想熟练地使用电脑 打字是基本的技能 一定要练习会盲打 练习好计算机键盘的盲打 盲打
  • CMake应用:集成gtest进行单元测试

    编写代码有bug是很正常的 通过编写完备的单元测试 可以及时发现问题 并且在后续的代码改进中持续观测是否引入了新的bug 对于追求质量的程序员 为自己的代码编写全面的单元测试是必备的基础技能 在编写单元测试的时候也能复盘自己的代码设计 是提
  • 记一次通过ftplib上传文件至ftp,遇到550 Failed to change directory及553 Could not creat file问题与解决

    遇到550及553错误后 排查思路 1 查看ftp上传路径是否从根目录开始 个人遇到的情况是 需求方提供的ftp地址存在隐藏目录 需求方提供的ftp地址为 ftp xx xx xxx xxx xxx input 这个地址可以正常访问 只不过
  • TPS5430和TPS54302调试艰辛之路

    此文用于记录个人调试中碰到的问题 也请各路大神不吝赐教指点迷津 该问题目前还没有解决也没有得到一个合理的解释 本人仍在探索 调试背景 功率需求 5V 0 1A 需要做一个小板子 功能就是将232通讯转换为485通讯 需要24V供电所以选了D
  • 【地图可视化】Echarts地图上展示3D柱体

    这是以前有这方面可视化的需求做的 找了很多资料 最后感觉这样的效果比较满意 效果展示 以下以江苏省的地图为例 数据准备 对于想要做3d效果的地区 需要准备对应的json文件 可以在这个网站上下载 数据最小粒度可以具体到县 DataV Geo
  • OpenCV曝光参数和快门时间的对应关系

    目录 1 曝光设置 2 设置自动曝光为手动曝光 3 曝光参数具体对应于曝光时间 4 代码实现 5 其他知识补充 5 1 相机曝光原理 5 2 快门速度 opencv Camera曝光设置 1 曝光设置 cv cap set cv CAP P
  • 插入排序 直接插入 C语言

    碎碎念念 基本思路是 一般先孤立这堆数字的第一个数 那么它自己一个就是有序了 再拿后面的数和它比较 找到大小位置合适的插进去 完了之后这一小堆还是有序的 再拿后面的来和前面的比较 找到合适的位置插进去 直到全部插完 代码 include
  • Arthas使用教程

    什么是 Arthas 摘录一段官方 Github 上的简介 Arthas 是Alibaba开源的Java诊断工具 深受开发者喜爱 当你遇到以下类似问题而束手无策时 Arthas 可以帮助你解决 这个类从哪个 jar 包加载的 为什么会报各种
  • 微信小程序(原生)使用Swiper实现(商品详情)视频和图片轮播(仿京东/淘宝商品详情头部视频+图片轮播)

    一 需求 1 如果第一是视频 不进行自动轮播 2 可以手动滑动切换 3 点击播放视频 也可以手动滑动切换 4 视频播放完后 自动轮播 5 视频可以点击暂停和全屏播放 二 最终效果 三 源码 播放icon使用了TDesign组件库 1 wxm
  • 同一个类的方法怎么Mock?spy函数啦

    大家好 我是神韵 是一个技术 生活博主 出文章目的主要是两个 一是好记忆不如烂笔头 记录总结中提高自己 二是希望我的文章可以帮到大家 欢迎来点赞打卡 你们的行动将是我无限的动力 本篇主题是 同一个类的方法怎么Mock spy函数啦 我在测试
  • C语言fscanf函数的理解

    第一次学文件时 没学太明白 在课程设计时又不得不使用fscanf 因此又复习了一下 fp1 fopen Data FindPassword Qusetion txt r fscanf fp1 s answer i 这意思就是将FindPas
  • idea报错:Parent ‘Unknown:Unknown:Unknown‘ has problems

    导入项目时报错 Parent Unknown Unknown Unknown has problems 问题阐述 查看maven的setting xml文件 值得注意的一点 问题阐述 项目在导入之后 就报错了如下所示错误 Parent Un
  • 【CSS flex布局】用flex写个骰子

    注 新手练习 基本思路 HtML部分 一个大 ul 包裹6个 li 也就是6个骰子 每个 li 中的 span 对应一个骰子点数 ul li span span li li span span span span li li span sp
  • G. 积木画(dp + 滚动数组)

    大致题意 给定2 N的画布 以及两种积木 问填满画布的方法有多少种 思路 数据范围很大 时间复杂度要求O n 可以想到用线性dp来解决 考虑状态转移方程 状态表示 d i j 表示前 i 列都填满 填满第 i 1 列时状态为j的种类数 按j
  • 从hdfs读取image文件

    发现从hdfs直接读取image文件response Image open filepath 会报错路径不存在 出现这个问题是因为PIL的Image open filepath 只能打开本地路径里的文件 不能打开hdfs里的 而且hdfs是
  • (转)牛牛牌型判定(五小牛 > 五花牛 > 炸弹 > 银牛 > 牛牛 > 有牛>没牛)

    牌型大小 五小牛 gt 五花牛 gt 炸弹 gt 银牛 gt 牛牛 gt 有牛 牛987654321 gt 没牛 K gt Q gt J 2 gt A 黑桃 gt 红桃 gt 梅花 gt 方块 同样的牌型比大小 同样的手牌比花色 1 2 在
  • nzAutocomplete监听选择事件,做相应处理

    nzAutocomplete 当组件选择一个选项后 没有回调函数 但想在选择时获取相关的数据 可以通过点击事项 传入相关对象
  • excel 下载方法封装

    1 首先需要拿到后端返回的URL下载地址 2 写个下载方法 url 接口返回的下载地址 例如 https cancer research oss cn beijing aliyuncs com yuance platform permiss
  • Unity 3D 做FPS游戏

    Part 1 Introduction 第一部分 介绍 This tutorial will detail how to make a simple First Person Shooter FPS It will introduce fu