function Start () {
// GameObject の参照
print(gameObject);
// その GameObject が持っている Transform の参照 (2つは同じ結果)
print("gameObject.GetComponent(Transform)="+gameObject.GetComponent(Transform));
print("gameObject.transform ="+gameObject.transform);
}
var field=3;
function Start () {
// フィールド値の参照 (2つは同じ結果)
print("field ="+field);
print("this.field="+this.field);
// メソッドの呼び出し (2つは同じ結果)
MyFunction ();
this.MyFunction ();
// スクリプト Component (=this) が属している GameObject を取得する定義済みフィールド値 (2つは同じ結果)
print("gameObject ="+gameObject);
print("this.gameObject="+this.gameObject);
}
function MyFunction () {
print("function called");
}
function Start () {
// Transform の参照 (4つは同じ結果)
print("this.gameObject.transform="+this.gameObject.transform);
print("gameObject.transform ="+gameObject.transform);
print("this.transform ="+this.transform);
print("transform ="+transform);
}
function Update () {
if (Input.GetButtonDown ("Jump")) // ジャンプボタンを押したら
{
rigidbody.AddForce (0.0, 300.0, 0.0); // 高さ方向に力をかける
}
}
戻る