Nanashi-soft○プログラマ専用○Unityでゲーム開発○
this.transform.Translate(「X軸移動量」 * Time.deltaTime, 「Y軸移動量」 * Time.deltaTime, 「Z軸移動量」 * Time.deltaTime);
this.transform.Rotate(「X軸回転量」 * Time.deltaTime, 「Y軸回転量」 * Time.deltaTime, 「Z軸回転量」 * Time.deltaTime);
this.transform.LookAt(「オブジェクト」.transform.position);
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(「オブジェクト」.transform.position), Time.time * 0.01);
if (0.1 < Vector3.Distance(this.transform.position, 「オブジェクト」.transform.position)) {
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(「オブジェクト」.transform.position - this.transform.position), Time.time * 0.1);
this.transform.position = this.transform.position + this.transform.forward * Time.time * 0.01;
}
オブジェクトの方を向きながら,近づいていきますvar kakudo : float = 0;をグローバル変数に宣言
var r : float = Vector3.Distance(this.transform.position, 「オブジェクト」.transform.position); var rad : float = kakudo * Mathf.Deg2Rad; this.transform.position.x = 「オブジェクト」.transform.position.x + r * Mathf.Cos(rad); this.transform.position.z = 「オブジェクト」.transform.position.z + r * Mathf.Sin(rad); kakudo = kakudo + 0.5;