iT邦幫忙

2025 iThome 鐵人賽

DAY 27
0
自我挑戰組

從零開始學習Unity引擎系列 第 27

unity學習day27--製作遊戲(6)

  • 分享至 

  • xImage
  •  

緊接上回

當然了,一個一個放的話總共要放50個,而且還要計算每個台階的距離,保證距離一致,搞不好到時候還會出現根號的情況,腦子正常的人都不會想要手動放滿50個台階,因為要計算的的不只是距離,還有每個台階的旋轉角度,所以這時候就要用到腳本了,把這種大量計算的事情還是交給機器吧。在“Scripts”下面建立腳本命名為“GenerateSpiralSteps”,接著寫一個生成剩餘49個台階的腳本。
https://ithelp.ithome.com.tw/upload/images/20250929/201783737JqV9ShCSg.png
https://ithelp.ithome.com.tw/upload/images/20250929/20178373AiJqu7gIuM.png

在“Templete”欄位把“Step_01”拖進來,直接手動搜尋,其他的值都用預設,最後點擊右上角的三個點,點擊“產生”就會出現剩餘的49個台階。
https://ithelp.ithome.com.tw/upload/images/20250929/20178373I3ej7wzroH.png

在“CenterPivot”下面建立立方體子物件“B_EndPlatform”,“ B_EndPlatform”的相對位置是(8,71,-1.7),縮放是(3,0.4,3),最後把“M_Grass”掛上。
https://ithelp.ithome.com.tw/upload/images/20250929/20178373vtTM2nSI56.png

從“Prefabs”把“RedCoin”拖到“CenterPivot”底下成為它的子物件並且改名為“RedCoin_03”,相對位置為(8,71.8, -1.7),這是第三個重生點。
https://ithelp.ithome.com.tw/upload/images/20250929/20178373Etsq6OrTZZ.png

接著把“GiantTree”的縮放設為(25,75,25),並且要勾選碰撞器。
https://ithelp.ithome.com.tw/upload/images/20250929/20178373eZFEOquKiC.png

最後記得給台階加上材質,只不過要一個一個拖,拖滿50個,因為不用填參數,所以就不寫腳本了,一個個拖上去比寫腳本輕鬆。
https://ithelp.ithome.com.tw/upload/images/20250929/20178373v6VHQKm03X.png


上一篇
unity學習day26--製作遊戲(5)
下一篇
unity學習day28--製作遊戲(7)
系列文
從零開始學習Unity引擎28
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言