3D專案:John Lemon
P118 新增角色動畫
新增控制器
- Assets
- Models
- Characters
- John Lemon
- Characters
- Models
新增至Hierarchy,再新增至Prefabs,進入Prefab編輯
- Animators
- Create Animator Controller
- 拖入Animation,右鍵,Make Transmission
- Parameters, +, IsWalking, 選中transmission, conditions, +, IsWalking,
- 將Animator Controller拖入
點選, 即可看到效果
P119 更改動畫bug
新增rigidbody
update Mode: Animate Physics
P120 玩家程式碼
建立向量,表示移動
建立變數,獲取輸入
private void FixedUpdate()
{
m_Movement.Set()
}
建立剛體和動畫管理器
Start():
獲取剛體元件;
獲取動畫控制組件;
update 和 fixedupdate的區別:一些物理屬性的更新操作應該放在FixedUpdate中操作。
判斷是否存在移動
23點04分
但是旋轉還是沒用成功
2022年2月21日
-
在遊戲中給遊戲物件新增component
-
在C#中構造變數:
- 變數有各種各樣的,需要構造合適的變數
-
對變數進行各種運算處理
- 接收使用者輸入
將變數與component關聯起來
根據對變數的處理結果,對component進行操作
14點41分
-
重新看了一遍視訊,並跟視訊檢查了一下程式碼,沒有發現問題。
-
準備除錯的時候,配置了launch.json,發現不能除錯,但重新運行遊戲的時候,發現John可以轉身了。
-
報錯內容為:
error while processing request 'launch'(exception:未將物件引用設定到物件的例項。) -
將之前的tasks.json複製到.vscode資料夾下,可以除錯了,但是不能在此狀態下進行使用者輸入。
2022年2月22日
OnAnimatorMove()方法:
當動畫播放引發根移動時執行
P122 場景和光照簡介
window->Rendering->Environment->Environment Lighting-> Gradient
Equator:地平線向場景中傳播的光線
Ground:場景下方的光線
P124 使用NavMesh導航系統
-
Hierarchy > level > √ static > 包含子物件
- 被標記為static的Mesh Render元件,可用於導航網格。
- 被標記為static的物件,在渲染過程中就被當作導航網格。
- Corridors > Dressing > CeilingPlane > 不標記為static
-
AI > Navigation > Bake > Agent radius > 0.25 -> Bake
但此時不顯示藍色地板- 點開Gizmos
-
Off-Mesh Link:非直接相連
P125 使用Cinemachine
-
沒有在視訊教程所教的位置找到這個Cinemachine
-
GameObject > Cinemachine
-
CM vcam1 > Body > Framing transposer -> Aim > Do nothing -> Rotation > x > 45
-
-> follow (拖過來)JohnLemon
P126 後期特效簡介
Render Pipeline的概念
渲染管線
內建渲染管線
著色器
抗鋸齒
- 選中main camera > Tags & Layers > layer > add new layer > PostProcessingVolumes
- main Camera > add component > post-process Layer > Layer > PostProcessingVolumes -> Fast mode 打勾
P127 後期處理體積 新增顏色分級 泛光
後期處理體積
- Create Empty > 重新命名為GlobalPost -> 選擇層為PostProcessingVolumes
- -> 新增元件 > Post-process Volume > Position 定位0,0,0 -> 打勾 Is Global
- 新增配置檔案 > Profile > New > 將在Scenes資料夾下建立一個“scene檔名_Profiles”資料夾,其中有GlobalPost
- GlobalPost > Add effect > color grading
- Tonemapping > √ Mode > ACES
- Tone > Postexposure
軌跡球 trackballs
- Lift會影響陰影的顏色
- Gain:影響最亮的高光
- Gamma: 涵蓋影象顏色中間(或中間範圍)的所有內容
泛光 bloom
- All
- Intensity 2.5
- Threshold 0.75
P128 新增環境光遮擋&漸暈&鏡頭失真
Ambient Occlusion
- All
- Intensity 0.5
- Thickness modifier 3.5
漸暈 Vignette
- Intensity 0.5
- Smoothness 0.3
Lens distortion
- Scale 1.1
- Intensity 30
P129 設定遊戲結束UI
- Hierarchy > UI > Image
? Image的Anchors不能修改
- 但是可以滑鼠拖動
修改錨點 > 修改Image邊緣與錨點確定的邊界的距離
------------恢復內容開始------------
# P118 新增角色動畫 ## 新增控制器 * Assets * Models * Characters * John Lemon新增至Hierarchy,再新增至Prefabs,進入Prefab編輯
- Animators
- Create Animator Controller
- 拖入Animation,右鍵,Make Transmission
- Parameters, +, IsWalking, 選中transmission, conditions, +, IsWalking,
- 將Animator Controller拖入
點選, 即可看到效果
P119 更改動畫bug
新增rigidbody
update Mode: Animate Physics
P120 玩家程式碼
建立向量,表示移動
建立變數,獲取輸入
private void FixedUpdate()
{
m_Movement.Set()
}
建立剛體和動畫管理器
Start():
獲取剛體元件;
獲取動畫控制組件;
update 和 fixedupdate的區別:一些物理屬性的更新操作應該放在FixedUpdate中操作。
判斷是否存在移動
23點04分
但是旋轉還是沒用成功
2022年2月21日
-
在遊戲中給遊戲物件新增component
-
在C#中構造變數:
- 變數有各種各樣的,需要構造合適的變數
-
對變數進行各種運算處理
- 接收使用者輸入
將變數與component關聯起來
根據對變數的處理結果,對component進行操作
14點41分
-
重新看了一遍視訊,並跟視訊檢查了一下程式碼,沒有發現問題。
-
準備除錯的時候,配置了launch.json,發現不能除錯,但重新運行遊戲的時候,發現John可以轉身了。
-
報錯內容為:
error while processing request 'launch'(exception:未將物件引用設定到物件的例項。) -
將之前的tasks.json複製到.vscode資料夾下,可以除錯了,但是不能在此狀態下進行使用者輸入。
2022年2月22日
OnAnimatorMove()方法:
當動畫播放引發根移動時執行
P122 場景和光照簡介
window->Rendering->Environment->Environment Lighting-> Gradient
Equator:地平線向場景中傳播的光線
Ground:場景下方的光線
P124 使用NavMesh導航系統
- 遊戲物件 > static
- AI > Navigation > Bake > Agent radius > 0.25 -> Bake
但此時不顯示藍色地板 - 點開Gizmos
P125 使用Cinemachine
-
沒有在視訊教程所教的位置找到這個Cinemachine
-
GameObject > Cinemachine
-
CM vcam1 > Body > Framing transposer -> Aim > Do nothing -> Rotation > x > 45
-
-> follow (拖過來)JohnLemon
P126 後期特效簡介
Render Pipeline的概念
渲染管線
內建渲染管線
著色器
抗鋸齒
- 選中main camera > Tags & Layers > layer > add new layer > PostProcessingVolumes
- main Camera > add component > post-process Layer > Layer > PostProcessingVolumes -> Fast mode 打勾
P127 後期處理體積 新增顏色分級 泛光
後期處理體積
- Create Empty > 重新命名為GlobalPost -> 選擇層為PostProcessingVolumes
- -> 新增元件 > Post-process Volume > Position 定位0,0,0 -> 打勾 Is Global
- 新增配置檔案 > Profile > New > 將在Scenes資料夾下建立一個“scene檔名_Profiles”資料夾,其中有GlobalPost
- GlobalPost > Add effect > color grading
- Tonemapping > √ Mode > ACES
- Tone > Postexposure
軌跡球 trackballs
- Lift會影響陰影的顏色
- Gain:影響最亮的高光
- Gamma: 涵蓋影象顏色中間(或中間範圍)的所有內容
泛光 bloom
- All
- Intensity 2.5
- Threshold 0.75
P128 新增環境光遮擋&漸暈&鏡頭失真
Ambient Occlusion
- All
- Intensity 0.5
- Thickness modifier 3.5
漸暈 Vignette
- Intensity 0.5
- Smoothness 0.3
Lens distortion
- Scale 1.1
- Intensity 30
P129 設定遊戲結束UI
- Hierarchy > UI > Image
? Image的Anchors不能修改
- 但是可以滑鼠拖動
修改錨點 > 修改Image邊緣與錨點確定的邊界的距離
2022年2月23日
P130 新增遊戲結束程式碼邏輯
- Hierarchy > Creat Empty > 重新命名為GameEnding > Box collider > 設定位置 > √ Is trigger
- Scripts資料夾新建 >
? Unity3d_can't add the script component "" because the script class cannot be found
- 指令碼中的
public class NewBehaviourScript : MonoBehaviour
改為public class GameEnding : MonoBehaviour
就好了
? 結束畫面中,背景圖透明
- ExitImageBackground> Image > color > A > 255
P131 加入石像鬼敵人
-
Model > Gargoyle
-
建立 Animator Controller,雙擊編輯
-
把Animation拖進Animator Controller的編輯頁面
-
把Animator Controller拖入遊戲物件Animator元件中的Controller中。
-
新增Capsule Collider
-
在Gargoyle下Create Empty重新命名為PointOfView,在local模式下調整角度(實質上就是建立了一個座標系,之後再在該座標系上新增碰撞體元件)
-
新增capsule Collider,direction調整為z軸
2022年2月24日
P132 為石像鬼新增程式碼
- 沒有顯示 you are caught,但可正常顯示won
- Gargoyle > PointOfView > √ Is trigger
- 進入區域,顯示won,並退出遊戲
- GameEnding.cs >
void EndLevel(CanvasGroup imageCanvasGroup, bool doRestart){...}
>exitBackgroundImageCanvasGroup.alpha
改為imageCanvasGroup.alpha
- 顯示 you are caught,但直接退出了遊戲
if(doRestart)
{
SceneManager.LoadScene(0);
}
UnityEditor.EditorApplication.isPlaying = false;
改為:
if(doRestart)
{
SceneManager.LoadScene(0);
}
else
{
UnityEditor.EditorApplication.isPlaying = false;
}
- 完成!
P133 為石像鬼新增程式碼替代方法
// 使用Resources方法,可以直接讀取專案資料夾Assets/Resources 中的檔案
spriteCaught = Resources.Load<Sprite>("Caught");
- 按照教程修改了GameEnding的掛接Script:MyGameEnding
- 只有到達exit的時候正確顯示Won,在觸碰石像鬼視野的時候,不能顯示Caught > 應該是 Observer的問題。
- Bingo! Observer.cs中:
public GameEnding myGameEnding;
改為public MyGameEnding myGameEnding;
- 修改之後,需要重新掛接一下GameEnding物件。
- MyGameEnding中:
exitBackgroundImageCanvasGroup.alpha
前增加image.sprite = sprite;
- exitBackgroundImageCanvasGroup > ExitImage > Source Image > None
2022年2月25日
P134 新增幽靈敵人
------------恢復內容開始------------
# P118 新增角色動畫 ## 新增控制器 * Assets * Models * Characters * John Lemon新增至Hierarchy,再新增至Prefabs,進入Prefab編輯
- Animators
- Create Animator Controller
- 拖入Animation,右鍵,Make Transmission
- Parameters, +, IsWalking, 選中transmission, conditions, +, IsWalking,
- 將Animator Controller拖入
點選, 即可看到效果
P119 更改動畫bug
新增rigidbody
update Mode: Animate Physics
P120 玩家程式碼
建立向量,表示移動
建立變數,獲取輸入
private void FixedUpdate()
{
m_Movement.Set()
}
建立剛體和動畫管理器
Start():
獲取剛體元件;
獲取動畫控制組件;
update 和 fixedupdate的區別:一些物理屬性的更新操作應該放在FixedUpdate中操作。
判斷是否存在移動
23點04分
但是旋轉還是沒用成功
2022年2月21日
-
在遊戲中給遊戲物件新增component
-
在C#中構造變數:
- 變數有各種各樣的,需要構造合適的變數
-
對變數進行各種運算處理
- 接收使用者輸入
將變數與component關聯起來
根據對變數的處理結果,對component進行操作
14點41分
-
重新看了一遍視訊,並跟視訊檢查了一下程式碼,沒有發現問題。
-
準備除錯的時候,配置了launch.json,發現不能除錯,但重新運行遊戲的時候,發現John可以轉身了。
-
報錯內容為:
error while processing request 'launch'(exception:未將物件引用設定到物件的例項。) -
將之前的tasks.json複製到.vscode資料夾下,可以除錯了,但是不能在此狀態下進行使用者輸入。
2022年2月22日
OnAnimatorMove()方法:
當動畫播放引發根移動時執行
P122 場景和光照簡介
window->Rendering->Environment->Environment Lighting-> Gradient
Equator:地平線向場景中傳播的光線
Ground:場景下方的光線
P124 使用NavMesh導航系統
-
Hierarchy > level > √ static > 包含子物件
- 被標記為static的Mesh Render元件,可用於導航網格。
- 被標記為static的物件,在渲染過程中就被當作導航網格。
- Corridors > Dressing > CeilingPlane > 不標記為static
-
AI > Navigation > Bake > Agent radius > 0.25 -> Bake
但此時不顯示藍色地板- 點開Gizmos
-
Off-Mesh Link:非直接相連
P125 使用Cinemachine
-
沒有在視訊教程所教的位置找到這個Cinemachine
-
GameObject > Cinemachine
-
CM vcam1 > Body > Framing transposer -> Aim > Do nothing -> Rotation > x > 45
-
-> follow (拖過來)JohnLemon
P126 後期特效簡介
Render Pipeline的概念
渲染管線
內建渲染管線
著色器
抗鋸齒
- 選中main camera > Tags & Layers > layer > add new layer > PostProcessingVolumes
- main Camera > add component > post-process Layer > Layer > PostProcessingVolumes -> Fast mode 打勾
P127 後期處理體積 新增顏色分級 泛光
後期處理體積
- Create Empty > 重新命名為GlobalPost -> 選擇層為PostProcessingVolumes
- -> 新增元件 > Post-process Volume > Position 定位0,0,0 -> 打勾 Is Global
- 新增配置檔案 > Profile > New > 將在Scenes資料夾下建立一個“scene檔名_Profiles”資料夾,其中有GlobalPost
- GlobalPost > Add effect > color grading
- Tonemapping > √ Mode > ACES
- Tone > Postexposure
軌跡球 trackballs
- Lift會影響陰影的顏色
- Gain:影響最亮的高光
- Gamma: 涵蓋影象顏色中間(或中間範圍)的所有內容
泛光 bloom
- All
- Intensity 2.5
- Threshold 0.75
P128 新增環境光遮擋&漸暈&鏡頭失真
Ambient Occlusion
- All
- Intensity 0.5
- Thickness modifier 3.5
漸暈 Vignette
- Intensity 0.5
- Smoothness 0.3
Lens distortion
- Scale 1.1
- Intensity 30
P129 設定遊戲結束UI
- Hierarchy > UI > Image
? Image的Anchors不能修改
- 但是可以滑鼠拖動
修改錨點 > 修改Image邊緣與錨點確定的邊界的距離
------------恢復內容開始------------
# P118 新增角色動畫 ## 新增控制器 * Assets * Models * Characters * John Lemon新增至Hierarchy,再新增至Prefabs,進入Prefab編輯
- Animators
- Create Animator Controller
- 拖入Animation,右鍵,Make Transmission
- Parameters, +, IsWalking, 選中transmission, conditions, +, IsWalking,
- 將Animator Controller拖入
點選, 即可看到效果
P119 更改動畫bug
新增rigidbody
update Mode: Animate Physics
P120 玩家程式碼
建立向量,表示移動
建立變數,獲取輸入
private void FixedUpdate()
{
m_Movement.Set()
}
建立剛體和動畫管理器
Start():
獲取剛體元件;
獲取動畫控制組件;
update 和 fixedupdate的區別:一些物理屬性的更新操作應該放在FixedUpdate中操作。
判斷是否存在移動
23點04分
但是旋轉還是沒用成功
2022年2月21日
-
在遊戲中給遊戲物件新增component
-
在C#中構造變數:
- 變數有各種各樣的,需要構造合適的變數
-
對變數進行各種運算處理
- 接收使用者輸入
將變數與component關聯起來
根據對變數的處理結果,對component進行操作
14點41分
-
重新看了一遍視訊,並跟視訊檢查了一下程式碼,沒有發現問題。
-
準備除錯的時候,配置了launch.json,發現不能除錯,但重新運行遊戲的時候,發現John可以轉身了。
-
報錯內容為:
error while processing request 'launch'(exception:未將物件引用設定到物件的例項。) -
將之前的tasks.json複製到.vscode資料夾下,可以除錯了,但是不能在此狀態下進行使用者輸入。
2022年2月22日
OnAnimatorMove()方法:
當動畫播放引發根移動時執行
P122 場景和光照簡介
window->Rendering->Environment->Environment Lighting-> Gradient
Equator:地平線向場景中傳播的光線
Ground:場景下方的光線
P124 使用NavMesh導航系統
- 遊戲物件 > static
- AI > Navigation > Bake > Agent radius > 0.25 -> Bake
但此時不顯示藍色地板 - 點開Gizmos
P125 使用Cinemachine
-
沒有在視訊教程所教的位置找到這個Cinemachine
-
GameObject > Cinemachine
-
CM vcam1 > Body > Framing transposer -> Aim > Do nothing -> Rotation > x > 45
-
-> follow (拖過來)JohnLemon
P126 後期特效簡介
Render Pipeline的概念
渲染管線
內建渲染管線
著色器
抗鋸齒
- 選中main camera > Tags & Layers > layer > add new layer > PostProcessingVolumes
- main Camera > add component > post-process Layer > Layer > PostProcessingVolumes -> Fast mode 打勾
P127 後期處理體積 新增顏色分級 泛光
後期處理體積
- Create Empty > 重新命名為GlobalPost -> 選擇層為PostProcessingVolumes
- -> 新增元件 > Post-process Volume > Position 定位0,0,0 -> 打勾 Is Global
- 新增配置檔案 > Profile > New > 將在Scenes資料夾下建立一個“scene檔名_Profiles”資料夾,其中有GlobalPost
- GlobalPost > Add effect > color grading
- Tonemapping > √ Mode > ACES
- Tone > Postexposure
軌跡球 trackballs
- Lift會影響陰影的顏色
- Gain:影響最亮的高光
- Gamma: 涵蓋影象顏色中間(或中間範圍)的所有內容
泛光 bloom
- All
- Intensity 2.5
- Threshold 0.75
P128 新增環境光遮擋&漸暈&鏡頭失真
Ambient Occlusion
- All
- Intensity 0.5
- Thickness modifier 3.5
漸暈 Vignette
- Intensity 0.5
- Smoothness 0.3
Lens distortion
- Scale 1.1
- Intensity 30
P129 設定遊戲結束UI
- Hierarchy > UI > Image
? Image的Anchors不能修改
- 但是可以滑鼠拖動
修改錨點 > 修改Image邊緣與錨點確定的邊界的距離
2022年2月23日
P130 新增遊戲結束程式碼邏輯
- Hierarchy > Creat Empty > 重新命名為GameEnding > Box collider > 設定位置 > √ Is trigger
- Scripts資料夾新建 >
? Unity3d_can't add the script component "" because the script class cannot be found
- 指令碼中的
public class NewBehaviourScript : MonoBehaviour
改為public class GameEnding : MonoBehaviour
就好了
? 結束畫面中,背景圖透明
- ExitImageBackground> Image > color > A > 255
P131 加入石像鬼敵人
-
Model > Gargoyle
-
建立 Animator Controller,雙擊編輯
-
把Animation拖進Animator Controller的編輯頁面
-
把Animator Controller拖入遊戲物件Animator元件中的Controller中。
-
新增Capsule Collider
-
在Gargoyle下Create Empty重新命名為PointOfView,在local模式下調整角度(實質上就是建立了一個座標系,之後再在該座標系上新增碰撞體元件)
-
新增capsule Collider,direction調整為z軸
2022年2月24日
P132 為石像鬼新增程式碼
- 沒有顯示 you are caught,但可正常顯示won
- Gargoyle > PointOfView > √ Is trigger
- 進入區域,顯示won,並退出遊戲
- GameEnding.cs >
void EndLevel(CanvasGroup imageCanvasGroup, bool doRestart){...}
>exitBackgroundImageCanvasGroup.alpha
改為imageCanvasGroup.alpha
- 顯示 you are caught,但直接退出了遊戲
if(doRestart)
{
SceneManager.LoadScene(0);
}
UnityEditor.EditorApplication.isPlaying = false;
改為:
if(doRestart)
{
SceneManager.LoadScene(0);
}
else
{
UnityEditor.EditorApplication.isPlaying = false;
}
- 完成!
P133 為石像鬼新增程式碼替代方法
// 使用Resources方法,可以直接讀取專案資料夾Assets/Resources 中的檔案
spriteCaught = Resources.Load<Sprite>("Caught");
- 按照教程修改了GameEnding的掛接Script:MyGameEnding
- 只有到達exit的時候正確顯示Won,在觸碰石像鬼視野的時候,不能顯示Caught > 應該是 Observer的問題。
- Bingo! Observer.cs中:
public GameEnding myGameEnding;
改為public MyGameEnding myGameEnding;
- 修改之後,需要重新掛接一下GameEnding物件。
- MyGameEnding中:
exitBackgroundImageCanvasGroup.alpha
前增加image.sprite = sprite;
- exitBackgroundImageCanvasGroup > ExitImage > Source Image > None
2022年2月25日
P134 新增幽靈敵人
2022年2月26日
P137 新增非劇情音效
- Hierarchy > Creat Empty > 更名為 Audio > Transform > reset
- 在Audio下 > Creat Empty > Rename: Ambience > √ loop > volume
- -> Create New > Rename:Escape > 拖入SFXWin > 取消 √ Play on awake
public AudioSource audioClip;
audioClip.Play();
2022年2月27日
P138 新增玩家腳步聲音
P139 新增鬼魂聲效
- 為了音效更加逼真,把Audio Listener元件從Main Camera移至John Lemon.
- Spatial Blend > 設定為3D > 3D Sound Settings > Max Distance > 10
- ? Ghost突然不會巡邏了
force to Mono: 強制單聲道