WER
CTRL +? D復制
雙擊左邊 和 F 以選中物體為中心顯示
clobal local
y軸 up
z軸 forward
x軸 right?
transform
void Start()
{
? ? Debug.Log("開始測試");
? ? GameObject obj = this.gameObject;
? ? string name = obj.name;
? ? Debug.Log("物體名稱:" + this.gameObject.name);
? ? Transform tr = this.gameObject.transform;
? ? Vector3 pos = this.gameObject.transform.position;
? ? Debug.Log("物體位置:" + pos.ToString("f3"));
? ? obj.transform.position = new Vector3(0, 0, 0);
????obj.transform.localPosition = new Vector3(0, 0, 0);
Application.targetFrameRate = 60;//盡量以60來更新幀率
}
void Update() // 更新游戲狀態(tài)
{
? ? Debug.Log("upate:" + Time.time);
Debug.Log("upate:" + Time.deltaTime);//與上一次的時間間隔
//使用deltaTime 讓物體勻速運動
float speed = 1;
float distance = speed * Time.deltaTime;
//讓物體運動
Vector3 pos = this.transform.localPosition;
pos.x -= distance; //0.1f;
this.transform.localPosition = pos;
}