Unity Tutorial - Survival Shooter 實作
Version 5.1
Unity官網上的教學Survival-Shooter-Project實作
Outline
記錄
Chap02
Drag,AngularDrag:阻力大小,角阻力- 設定Infinity會使移動完成(放開鍵盤)後立刻停止
GetComponent<T>Get type T component from this objectRigidbody(剛體):屬於物理運動的物件- Update 和 FixUpdate
Anim.SetTrigger(String): 啟動animator的triggerInput.GetAxisRaw("Horizontal");,Input.GetAxisRaw("Vertical");:鍵盤輸入Input.mousePosition:滑鼠位置floorHit:滑鼠對應到遊戲中地板的位置,用投影方式算出Quaternion:四元數,用來旋轉
Chap03
offset = transform.position - target.position;: camera 和 player 的距離(固定)Vector3.Lerp: 內插法移動至 player位置+offset
Chap04
hitParticles: 屬於ParticleSystem(粒子系統)- 被打的特效
- Nav Mesh Agent(尋路agent)
- Use Windows → navigation to bake
Chap05
Handle Slide Area: 控制UI.Slide的移動,移除後無法變更Slide
Chap07
OnTriggerEnter (Collider other)被其他Collider碰到時自動呼叫OnTriggerExit (Collider other)離開
GetComponentInChildren: 可以拿child的objectGameObject.FindGameObjectWithTag ("Player");: 拿取其他objectcapsuleCollider.isTrigger = true;: 模擬被Trigger的情況 → 會依序呼叫OnTriggerEnter,OnTriggerExitRigidbody.isKinematic = true;:使其得到物理性質(預設即有,只是之前關掉了)Destroy (gameObject, 2f);: 在2秒後將呼叫者摧毀Input.GetButton("Fire1"): 滑鼠左鍵或left controlLineRenderer: 線渲染器渲染有寬度並可以被賦予貼圖的線,可設置顏色,寬度gunLine.SetPosition((int) index, Vetor3 position)- 依照index順序的端點畫出線
timer += Time.deltaTimeinUpdate: 計算經過時間Physics.Raycast((Ray)shootRay,(RayCastHit)out shootHit,(float)range,(int)shootableMask): 計算shootHit(擊中的地方),限制在shootableMask上shootableMask = LayerMask.GetMask ("Shootable");
transform.forward: 物體面對的方向
Chap09
InvokeRepeating ("Spawn", delayTime, loopTime);: Call "Spawn" function after delayTime and continue calling after loopTimeInstantiate: 產生物件
Chap10
- 物件會照Hierarchy的順序render到螢幕
Application.LoadLevel(Application.loadedLevel);: 重新載入此場景(scene)
遇到的問題
Chap02
PlayerAC -- 設定箭頭時要取消勾選Has Exit Time
Chap04
Bake: set Width Inaccuracy % to 1 -- Unity5 找不到 → 不影響
Chap05
CanvasGroup → 直接在 Add Component 處尋找