




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、1-1 建Asset Level1 1-1 建Asset Level1 在 packagesUnity3D asset 套件,如果Unity3D 很多功能asset asset 表示它所屬的套件并沒有被匯入,這時(shí)候只要馬上匯入所需的套件就可以使用這些 2assetasset 必須事先以其它Unity3D asset 大抵分為貼圖材質(zhì)、3D 2assetasset 必須事先以其它Unity3D asset 大抵分為貼圖材質(zhì)、3D asset Asteroid.tga SimpleShip.psd SimpleShip0.tga Stars_large00 星空貼圖(上半部) Stars_larg
2、e01 星空貼圖(下半部)二、3D 模型Asteroid.fbx Asteroid-lambert4.mat Mortars 迫3 PhotongunSimpleShip0.tga Stars_large00 星空貼圖(上半部) Stars_large01 星空貼圖(下半部)二、3D 模型Asteroid.fbx Asteroid-lambert4.mat Mortars 迫3 Photongunshot 的4按正式開始,這時(shí)候玩家進(jìn)入所謂的第一關(guān)場景,接著是第二關(guān)、第三關(guān)、.,游 。按正式開始,這時(shí)候玩家進(jìn)入所謂的第一關(guān)場景,接著是第二關(guān)、第三關(guān)、.,游 。正式開始的場景則做為第二場景,名稱
3、叫 與從spacebag 的5 enuProject 在Project 窗口內(nèi)建立一個(gè)名為Scenes 這個(gè)代號呼叫 級代號來切換場景,場景在ScenesinBuild表里的層級順序就不要再任意變更,免得程序Project 窗口把場景拖曳到ScenesinBuild窗體里,并依下圖調(diào)整層級順序:7Level1 Level1 Project 7Level1 Level1 Project 1.Background Projection OrthographicSize 4. Transform tition 和ion 分別為(0,1,- Scenes拖曳到 Build Settings窗口的Sce
4、nes in Build 窗8Scenes拖曳到 Build Settings窗口的Scenes in Build 窗8 為 ition 設(shè)為(0,0,0)ion 設(shè)為(0,0,0)Scale 為1.5, 1.5)9 設(shè)為(1, 1,設(shè)為(50,為1.5, 1.5)9 設(shè)為(1, 1,設(shè)為(50,1-2 。Hero1.Player Player MeshFilter Cube 性 性 polySurface1 模型太小了,從目前的攝影機(jī)看不到,此時(shí)就要進(jìn)行下個(gè)步驟,把Player 2步驟:Project 窗口spacebag 0.01 1,改完后點(diǎn)選Apply2步驟:Project 窗口spa
5、cebag 0.01 1,改完后點(diǎn)選Apply3D 調(diào)三、 修改 Player 的碰撞模型(Collider)(1) 先移除目前的碰撞模型BoxCollider0.01 1 3 (2) 加入新的碰撞模型MeshCollider 4 (4) 修改pCube1步驟:Project 窗口spacebag5pCube1的尺度調(diào)整之后,Scene5pCube1的尺度調(diào)整之后,SceneInspector 窗口的MeshCollider的核選方塊取消然后0.01 1 6Player Project 窗口里建立一個(gè)新的數(shù)據(jù)匣Scripts6Player Project 窗口里建立一個(gè)新的數(shù)據(jù)匣Scripts
6、usingusingpublicclassPlayer:publicfloatPlayerSpeed; void Update () floatoutToMove=Input.GetAxisRaw(Horizontal)*PlayerSpeed*Time.del transform.Translate(Vector3.right * outToMove);Inspector 窗口中的公共變量PlyerSpeed5空飛幾,它會根據(jù)玩家按下鍵盤的A鍵或是D1或-1,這個(gè)數(shù)字再和代表太空度的 PlyerSpeed frame frame frame 過水平移動(dòng)使用的是(1,0,0)改用 點(diǎn)有8空飛幾
7、,它會根據(jù)玩家按下鍵盤的A鍵或是D1或-1,這個(gè)數(shù)字再和代表太空度的 PlyerSpeed frame frame frame 過水平移動(dòng)使用的是(1,0,0)改用 點(diǎn)有8畫x ifition.x=-ition=newVector3(8.25f, ifition=newVector3(-8.25f, Player.cs usingifition.x=-ition=newVector3(8.25f, ifition=newVector3(-8.25f, Player.cs usingusingpublicclassPlayer:publicfloatPlayerSpeed; void Updat
8、e () if(transform. ition.x=制作 造類似星際大戰(zhàn)的綠光雷射 。 (1) 為 (1) 為 Rigidbody 屬性GravityRigidbody 屬性Kinematic個(gè)只要讓 彈能夠一定的速度往上方飛去,直到離Projectile Script 把 個(gè)只要讓 彈能夠一定的速度往上方飛去,直到離Projectile Script 把 加到 GameObject usingpublicclassProjectile: public float ProjectileSpeed; void Start () myTransform=voidUpdate()myTransfo
9、rm.Translate(Vector3.up*編修完成后, 記得這里有個(gè)公共變量 ProjectileSpeedInspection Projectile ProjectileSpeed 為 10現(xiàn)在 彈的基已經(jīng)完成,不過大家一定覺得很奇怪,Unity3D 的 GameObject 一 現(xiàn)在 彈的基已經(jīng)完成,不過大家一定覺得很奇怪,Unity3D 的 GameObject 一 GameObject PrefabProjectilePrefab Prefab(1) 建立一個(gè)新的 PrefabProjectilePrefab GameObject 銷毀 彈往上方移動(dòng)Project Create
10、PrefabProjectilePrefab 拖曳至此將 Herarchy 窗口內(nèi)的 Projectile 拖曳到 ProjectilePrefab 里Herarchy 發(fā)射 發(fā)射 彈的程序?yàn)榱俗尦绦虼a可以存取 彈 發(fā)射 發(fā)射 彈的程序?yàn)榱俗尦绦虼a可以存取 彈 Prefab,usingusingpublicclassPlayer:publicfloatpublicGameObject. . Player.cs =+目前的坐標(biāo)產(chǎn)生一顆 彈:ition,if(Input.GetKeyDown(space) .發(fā)射 彈的當(dāng) 彈被 Instantiate()ProjectilePrefab 射 彈
11、程序代碼后的完整內(nèi)容:usingusing=+目前的坐標(biāo)產(chǎn)生一顆 彈:ition,if(Input.GetKeyDown(space) .發(fā)射 彈的當(dāng) 彈被 Instantiate()ProjectilePrefab 射 彈程序代碼后的完整內(nèi)容:usingusingpublicclassPlayer:publicfloatvoid Update () if(transform. ition.x= ition=newition.yition,if(transform. ition.x= ition=newition.yition,現(xiàn)在要在發(fā)射 彈時(shí)發(fā)出咻.咻.spacebag (1) Proje
12、ctilePrefab,再點(diǎn)選主選單ComponentAudioAudioSourceSourceProjectilePrefab里。查看一下它的AudioClip的內(nèi)容應(yīng)(3) 點(diǎn)選Audio Clip文件,請選擇Photongunshot 0.02(4) 確認(rèn)PlayOnAwake是否已勾選,如果沒有,請將它勾選起來,讓 彈生成時(shí),音效,發(fā)射 彈時(shí)已經(jīng)有聲音了:1-3 MeshFilter 一、 建立隕石 GameObject1-3 MeshFilter 一、 建立隕石 GameObject 都稱呼它為ition 與ion 均為(0,0,Scale 為(1.3,1.3,Enemy 的外型(
13、1) 把屬性SphereMeshFilter)改為pSolid3(2) Project Apply (2) Project Apply ) Enemy Enemy Collider 還是原來的球體Player 的 Player ColliderPlayer ColliderCollider 還是原來的球體Player 的 Player ColliderPlayer Collider的目的是為了碰撞偵測而設(shè)的,一般而言中的物體是否相互碰撞不是照Unity3D 在的Colider 做為隕石的 Collider。Enemy.csProject Scripts x=Random.Range(-7.0f
14、,MinSpeed MaxSpeed currentSpeed=floatoutToMove=currentSpeed*transform.Translate(Vector3.down*Enemyifition.y=-5).MinSpeed MaxSpeed currentSpeed=floatoutToMove=currentSpeed*transform.Translate(Vector3.down*Enemyifition.y=-5).的概念整理一下,然后完成 :/usingusingpublicclassEnemy: public float MinSpeed; public floa
15、t MaxSpeed; privatefloatcurrentSpeed; private float x, y, z;voidvoidUpdate()transform.Translate(Vector3.down*ifition.y1000)9Player.Lives 里(值是 Score 變量) 的/usingusingpublicclassPlayer:MonoBehaviour略 9Player.Lives 里(值是 Score 變量) 的/usingusingpublicclassPlayer:MonoBehaviour略 :if(otherObject.tag=enemy&e=
16、略10 Lose 現(xiàn)思考一下要在那里判斷生命值是否為0 呢?當(dāng)太被隕會先生,的敗/:usingusingpublicclassPlayer:MonoBehaviour略IEnumerator; yieldreturnnew/:usingusingpublicclassPlayer:MonoBehaviour略IEnumerator; yieldreturnnewif (Player.Lives0) while(blinkCount= !gameObject.renderer.enabled; if (gameObject.renderer.enabled=true) hooter2D yiel
17、dreturnnew略Lose Missed 變量)Player.Missed /usingusingpublicclassEnemy:MonoBehaviour略voidUpdate()transform.Translate(Vector3.down*ifition.y=-publicclassEnemy:MonoBehaviour略voidUpdate()transform.Translate(Vector3.down*ifition.y=-略1-6 細(xì)部調(diào)整畫Level1 (2) 設(shè)定Stars1ion、Scale 分別(3) Ctrl-畫Level1 (2) 設(shè)定Stars1ion、S
18、cale 分別(3) Ctrl-ition 為(0,17,3.5)(4) Spacebag 中將預(yù)先做好的星空圖Stars_large00Stars 別到Stars1與Stars2Inspector 的公共變量Speed1,星空背景效果就大功/usingusingpublicclassStars:publicfloatSpeed; void Update () floatoutToMove=Speed* ifition.y-12)ition new太空飛機(jī)來發(fā)射 彈或避開隕石,操作的難度也就會越來越高了。currentSpeed=所以只要在隕石被 彈摧毀之后把 MinSpeed MaxSpee
19、d 的數(shù)值調(diào)高,新隕石就有機(jī)會Projectile.cs 程序,每次隕石被 MinSpeed MaxSpeed usingpublicclassProjectile:MonoBehaviour略 MaxSpeed usingpublicclassProjectile:MonoBehaviour略 if(otherObject.tag=enemy)Prefab, ition, 并沒有處理隕石變大變小,它固定的Scale 就是(1.3,1.3,1.3),為了讓它可以以隨MinScale、MaxScaleScale 另外還要三個(gè)變量 CurrentScaleX、CurrentScaleY、Curre
20、ntScaleZMinScale Scale CurrentScaleX=Random.Range(MinScale,MaxScale); CurrentScaleY=Random.Range(MinScale,MaxScale); CurrentScaleZ=Random.Range(MinScale,MaxScale); / nemy.cs usingpublicclassEnemy:publicfloatpublic float MaxSpeed; private floatprivatefloatprivatefloat略publicvoid currentScaleX= currentScaleY= currentScaleZ = Random.Range(MinScale,MaxScale); curre
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 綠竹種植協(xié)議書
- 豬糞消納協(xié)議書
- 簽下分手協(xié)議書
- 彩票站聘任店員協(xié)議書
- 逃離離婚協(xié)議書
- 罐車合伙協(xié)議書
- 紙上夫妻協(xié)議書
- 電梯工程協(xié)議書
- 化工煤買賣合同協(xié)議書
- 小語種課程轉(zhuǎn)讓協(xié)議書
- 《剪映專業(yè)版:短視頻創(chuàng)作案例教程(全彩慕課版)》 課件 第8章 創(chuàng)作商業(yè)廣告
- 2024秋期國家開放大學(xué)《公共行政學(xué)》一平臺在線形考(形考任務(wù)一至三)試題及答案
- 富士相機(jī)FUJIFILM X100T用戶手冊
- 廣東省東莞市(2024年-2025年小學(xué)三年級語文)人教版期末考試(下學(xué)期)試卷(含答案)
- 化工和危險(xiǎn)化學(xué)品重大事故隱患考試試題(后附答案)
- 2024-2025學(xué)年新教材高中政治 第三單元 全面依法治國 9.1 科學(xué)立法教案 部編版必修3
- 烘焙食品廠生產(chǎn)員工手冊
- 農(nóng)業(yè)現(xiàn)代化背景下智能種植基地建設(shè)方案
- 中醫(yī)藥進(jìn)校園
- 機(jī)務(wù)維修作風(fēng)課件講解
- 垃圾清運(yùn)服務(wù)投標(biāo)方案技術(shù)方案
評論
0/150
提交評論