First Steps
Every platform game has its star character who the player controls. Our star is Lerpz.
 
第一步驟
每個平台的遊戲人物都有其明星誰是播放器控制。我們的明星是Lerpz。
 
Animating Lerpz
In this chapter we will look at:
• Implementing third-­person player and camera controls
• Controlling and blending animations
• Using particle systems to implement the jet-­pack’s thrusters
• Adding a blob-­shadow to the player
• Maintaining the player’s state
• Handling player health, death and re-­birth.
Before we can begin, we need to know what this game is all about.
In short, we need...
 
動畫 Lerpz
在這一章中,我們將著眼於:
•實施第三人稱播放器和相機控制
•控制和混合動畫
•使用粒子系統來實現的噴氣包的推進器
•添加一個 BLOB-陰影的球員
•維護球員的狀態
•處理球員健康,死亡和再- 出生。
在我們開始之前,我們需要知道這個遊戲是怎麼一回事。
總之,我們要...
 
The Plot
Our hero is Lerpz: an alien visiting Robot World Version 2.
This replaced Robot World Version 1, which suffered a particularly brutal segmentation fault and abruptly crashed into its sun many years ago.
情節
我們的英雄是Lerpz:一個外國人來訪的機器人世界第2版。
這就取代機器人世界版本1,遭受一種特別殘酷的分割故障和其Sun突然撞向很多年前。
 
Unfortunately, Lerpz has had some bad luck: his spaceship has been impounded by the corrupt local police.
After looking high and low, Lerpz has found his spaceship, but Every platform game has its star character who the player controls.
Our star is Lerpz. how can he get it back from Mr. Big’s nastier, obsessive-­compulsive cousin, Mr. Even Bigger?
 
不幸的是,Lerpz已取得了一些壞運氣:他的飛船已被扣押了腐敗的地方警察。
看後高與低,Lerpz找到了自己的太空船,但每個平台的遊戲都有它的明星人物誰是播放器控制。
我們的明星是Lerpz。他怎麼能找回來大先生的厲害,強迫表弟先生更大?
 
Mr. Bigger loves nothing more than artistically arranging fuel canisters on his floating patio. He particularly admires how they glow when he places them on hover pads. (And, of course, they’re cheaper than fitting normal garden lights.)
更大的愛先生無非藝術在他的安排燃料罐浮天井。他特別欽佩他們如何煥發他們的地方時,他就懸停墊。 (當然,他們價格比正常裝修花園燈。)
 
But there’s something Mr. Bigger hasn’t realized! Thanks to his penny-­pinching ways, Lerpz knows that if he collects all the fuel canisters, the power used to keep them hovering will overload the security system. This will shut down the impound lot’s fence and free Lerpz’s spaceship. Lerpz can then enter his spaceship, add the fuel from the cans and fly away to freedom.
但還有一些尚未實現更大先生!由於他的小氣方式,Lerpz知道,如果他收集所有的燃料罐,電源使用,使他們徘徊將超載的安全系統。這將關閉扣押了很多的圍欄和自由Lerpz的飛船。 Lerpz可以進入他的飛船,從添加燃料罐和自由飛走。
 
All our hero has to do is collect enough fuel canisters and the impound’s force field will automatically shut down. Lerpz can then get back into his space car and drive it away. Mr. Bigger’s hired robot guards will try to stop  erpz, but luckily, they’re not particularly bright.
我們所有的英雄所要做的就是收集足夠的燃料罐和扣押的力場將自動關閉。 Lerpz然後可以重新回到他的太空車,駕駛它了。先生更大的僱用警衛機器人將試圖阻止erpz,但幸運的是,他們並不是特別明亮。
 
Now that that’s out of the way, we can start fleshing out our hero.
現在,這出的方式,我們可以開始充實我們的英雄。
Introducing Lerpz
*Open the project up and view the Scenes-­>TheGame Scene. Our first step is to add Lerpz to our Scene:
*Open the Objects folder in the Project Pane;
*Drag the Lerpz Prefab into either the Scene View or the Hierarchy View;
*Click on the new Lerpz entry in the Hierarchy and rename it to Player;
*Keep the Player object selected, move the mouse over the Scene View and tap the F (focus) key to center the view on the Lerpz model.
*Move Lerpz onto the raised platform with the Jump Pad (the niche with the yellow chevrons), near the Jail. (See the screenshot on the next page.)
 
介紹 Lerpz
*打開和查看項目的場面-> TheGame場景。我們的第一個步驟是將 Lerpz加入到我們的場景:
*打開對象文件夾窗格中的項目;
*拖動 Lerpz Prefab進入無論是現場查看或層次觀;
*點擊進入新Lerpz層次結構中的重命名為播放器;
*保持Player對象選擇,移動鼠標,使景色查看和自來水的F(重點)鍵的中心查看有關 Lerpz模型。
*移動 Lerpz上所提出的平台與跳躍墊(黃色的利基與箭頭),附近的監獄。 (見截圖在下頁。)
 
If you click Play now, you should see Lerpz standing in the courtyard outside the jail.
At this stage, Lerpz cannot be moved and the camera also needs to be linked to our player's character.
 
如果您單擊播放現在,你應該看到Lerpz站在院子外的監獄。
在這個階段,Lerpz不能移動,相機也需要與我們的球員的性格。
 

 
However, a third-­person viewpoint camera requires a camera that can follow the player around. This seems simple enough until you realize the camera also needs to avoid getting scenery between the player's character and the camera's viewpoint. This can be achieved using raycasting to check for unwanted objects between the camera and player avatar, but there are some special cases to consider. For example:
然而,第三人稱視角照相機需要一個攝像頭,可以跟隨玩家左右。這似乎很簡單,直到你意識到該相機還需要避免風景之間的球員的性格和相機的觀點。這可以通過使用光線投射物體之間不必要的檢查和球員頭像攝像頭,但也有一些特殊情況需要考慮例如:

• What happens if Lerpz is backed up against a solid wall? Should the camera move above and look down on the player? Should it move to the side?
• What if an enemy gets between the camera and our player avatar?
• How should the player controls work? Should they be relative to the camera's view? If so, this could get very confusing if the camera moves in an unexpected direction to avoid an obstacle.
如果發生什麼 Lerpz備份打擊了堅實的牆?如果攝像機移動以上看不起的球員?如果它移動到一邊?
•如果敵人得到相機與我們的球員頭像?
•應該如何播放器控制工作?他們應該是相對於相機的看法?如果是這樣,這有可能會非常混亂,如果相機在一個意想不到的方向移動,以避免障礙。
 

A number of solutions for third-­person cameras have been tried over the years. It's arguable that none have ever been 100% perfect. Some solutions fade out anything between them and their focus, making walls or enemies semi-­transparent. Other options include cameras which follow the player around, but which will, if necessary,move through walls and buildings to keep the player's view consistent.
一個數字的解決方案對第三人的相機已經嘗試了多年。這是值得商榷都沒有100%完美有些解決方案淡出他們和他們之間的任何重點,使牆壁或敵人半透明。其他選項包括相機而跟隨玩家左右,但將在必要時通過移動牆壁和建築物,以保持球員的觀點是一致的
  
The project supplied with this tutorial includes a few different camera scripts, but for the purposes of this tutorial, we'll use SpringFollowCamera. You'll find it in the Project Pane inside the Camera sub-­folder of the Scripts  older.
項目提供本教程包含了幾個不同的相機腳本,但對於本教程的目的我們將使用SpringFollowCamera會發現它在項目窗格相機內的子文件夾的腳本舊。
  
 
*Drag the SpringFollowCamera script from the Project Pane onto the NearCamera object in the Hierarchy  Pane.
*Click Play.
*拖動 SpringFollowCamera腳本從項目窗格到NearCamera對象層次結構中的窗格。
*點擊播放。
 
You will get an error message. This appears just to the right of the Play, Pause and Step buttons at the bottom  of Unity’s window.
你會得到一個錯誤信息。這似乎只是右邊的播放,暫停和
一步按鈕底部的統一的窗口。
Bring up the Debug Console (Shift+Cmd+C / Shift+Ctrl+C on PC), if it is not already visible.
調出調試控制台(按Shift+ Cmd的+的C / Shift + Ctrl鍵+ C在PC機),如果它尚不可見。
 
This displays any warnings, errors and other debugging information from your game.
You will probably see a lot of copies of the error message repeated in the log.
Highlight one and the pane below the log will show a bit more information about this error message, as shown in image 3.1.
 
這將顯示任何警告,錯誤和其他調試信息你的遊戲。
你可能會看到很多的副本重複的錯誤信息在日誌中。
亮點之一,該窗格下方的日誌將顯示多一點有關此錯誤消息,顯示在圖像3.1。
 
 
TIP
Whenever possible, the Debug Log window will show a line linking to the offending GameObject in the Hierarchy, (or to the Project Pane if the fault is in a Prefab or Script). You can see this line in the screenshot above.
提示
只要有可能,調試日誌窗口會顯示一行鏈接到有問題的遊戲對象層次結構中(或項目窗格中,如果故障是在一個預製腳本)。你可以看到這條線在上面的截圖
 
 
The UnassignedReferenceException error type is one you will likely see very frequently if you’re new to Unity. It sounds scary, but all it means is that a script variable has not been set. The Debug Log explains this too, so let’s do as it suggests:
 
 UnassignedReferenceException錯誤類型是一個你可能會看到非常頻繁,如果你是新的統一。這聽起來很嚇人,它的意思是,一個腳本變量還沒有確定調試日誌這也解釋了,所以讓我們做,因為它意味著
 
 
*Click on the NearCamera object in the Hierarchy Pane and look at the Spring
Follow Camera (Script) Component’s properties.
點擊 NearCamera對象層次結構中的窗格,並期待在春季按照相機(腳本)組件的屬性
 
The Target property is set to None (Transform). This defines the target object we want the camera to point at, so let’s set it:
*Stop the game if you haven’t done so already.
*If it’s not already selected, click on the NearCamera object in the Hierarchy Pane.
*Drag our Player GameObject from the Hierarchy Pane onto the Target setting to set it.
 
Target屬性設置為 None變換)定義了目標對象,我們希望相機,所以讓我們設置它:
*停止遊戲,如果你還沒有這麼做
*如果沒有被選中點擊 NearCamera對象層次結構中的窗格。
*我們的球員遊戲物體拖動從層次結構窗格到目標設定來設置。
 
 
Making Changes While Playing
When you are playing the game, Unity will let you tweak the properties of the various game objects and components in the game. However, it will not save them! The moment you stop the game, any changes will be discarded!
If you want your changes to stick, always stop the game first!
播放時進行更改
您玩遊戲,統一會讓你調整屬性的各種遊戲對象和組件在遊戲中。但是,它不會他們!你停止了比賽,任何更改都將被丟棄
如果你想更改堅持總是停止遊戲的第一
 
 
If you click Play now, the camera still won't work. You will see a errors relating to the SpringFollowCamera script. It needs the target to have a ThirdPersonController script attached to it. This is because a third-­person camera is closely tied to the player controls: it needs to know what the player is doing so that it can react accordingly.
如果您單擊立即遊戲,相機仍然無法工作。你會看到一個錯誤有關SpringFollowCamera腳本。它需要有一個目標 ThirdPersonController腳本重視。這是因為第三人稱相機是緊密相關的播放器控制:它需要知道球員是這樣,它可以作出相應的反應
 
 
The final settings should look as shown in the image below:
最後的設置應如下所示圖片如下:
 
 
Experiment with the numbers if you don't like the way the camera works; this is a subjective judgement and there is no single correct setting for something like this.
實驗與號碼,如果你不喜歡的方式,相機工作,這是一個主觀的判斷,也沒有唯一正確的設置這樣的事情
 
This is the first in a series of dependencies that we need to deal with.
這是首次在一個系列依賴關係,我們需要處理
 
 
*Complete the connection between the camera and the player by dragging the ThirdPersonController script from the Scripts-­>Player folder in the Project Pane onto our Player GameObject (in the Hierarchy Pane). (This will break the Prefab connection.)
完成連接相機與玩家通過拖動 ThirdPersonController腳本從腳本-> Player文件夾中的項目窗格我們的球員遊戲物體層次結構中的窗格) (這將打破預製連接。)
 
 
The Third Person Controller script also has its own requirements and dependencies.
The most important of these is the Character Controller component. Luckily, the script already tells Unity about this, so Unity will add this component for us.
控制器腳本第三人也有其自身的要求和依賴。
其中最重要的是字符控制器組件幸運的是,劇本已經告訴團結關於這一點,所以此組件的統一將增加我們
 
Connections & Dependencies.
Unity excels at showing visual assets, but these also have to be connected to each other to provide the interactivity we expect from a game. These connections are difficult to show visually.
These connections are known as dependencies, and it's what you get when one object requires a second object to function. That second object may, in turn, require yet more
objects to work. The result is that your assets are tied to each other with myriad virtual bits of string -­-­ scripts -­-­ tying them all together to make a game.
Defining all these dependencies is a key element of game design.
連接和依賴。
統一擅長表現的視覺資產,但這些也可以連接到對方提供互動性,我們期望從一個遊戲。這些連接是很難直觀地顯示
這些連接被稱為依賴關係,這就是你當一個對象需要一個第二個對象的功能。第二個對象,可反過來需要更多的對象的工作。其結果是,你的資產相互聯繫在一起無數字符串 -腳本 -他們都在一起,使一個遊戲。
定義所有這些依賴一個關鍵因素遊戲設計
 
 
We now need to add a tag to our Player GameObject. This is so that scripts can find our Player in the Scene by simply telling Unity to find the GameObject with said tag.
我們現在需要添加一個標籤我們的球員遊戲對象這是為了讓腳本可以找到我們的球員在場景,只需告訴找到遊戲對象的統一與所述標記。
 
*With our Player object displayed in the Inspector, open the Tag drop-­down menu and choose the “Player” tag, as shown below.
隨著我們的球員督察對象中顯示,打開標籤的下拉菜單,選擇“播放器“標籤,如下圖所示。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 
 
 
 
 
 
 

 

arrow
arrow
    全站熱搜

    createps 發表在 痞客邦 留言(0) 人氣()