15. ? 修改BallController程式腳本,加入碰撞處理
using UnityEngine;
using System.Collections;
public class BallController : MonoBehaviour {
...
void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag ("Pick Up")) {
other.gameObject.SetActive (false);
}
}
}
? 測試遊戲,Diamond物件被Ball碰到時就會消失
收集道具
15
16. ? 選單命令GameObject> UI> Text,命名為Count Text
? Anchor Presets = top, left
? Pos(X, Y) = (0, 0)
? Width = 300, Height = 100
? Pivot(X, Y) = (0, 1)
? Text = Count Text
? Character/Font Size = 28
? Paragraph/Alignment = Center
? Color = white
顯示分數 1/5
16
17. ? 選單命令GameObject> UI> Text,命名為Win Text
? Anchor Presets = middle, center
? Pos(X, Y) = (0, 0)
? Width = 300, Height = 100
? Pivot(X, Y) = (0.5, 0.5)
? Text = Win Text
? Character/Font Size = 28
? Paragraph/Alignment = Center
? Color = Red
顯示分數 2/5
17
18. ? 修改BoardController程式腳本,加入記分處理
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class BoardController : MonoBehaviour {
public Text countText;
public Text winText;
private int count;
void Start () {
GetComponent<Rigidbody>().AddForce(transform.forward * 10f);
count = 0;
SetCountText ();
winText.text = "";
}
顯示分數 3/5
18