close

function Update () {             
        if (Input.GetKeyDown ("space"))      //當鍵盤按"下"+"上"   時
            print ("space key was pressed");  //顯示  space key was pressed
    }                             
-----------------------
function Update () {
        if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)   //垂直>0.1
        if (Input.GetKey ("up"))                              //當鍵盤按下時    後面  ,0.3是混和動畫時間
            animation.CrossFade("Run",0.3);
    else
        if (Input.GetKeyUp ("up"))                        //當鍵盤彈起時
            animation.CrossFade("Idle");
    }
--------------------------    
function Update () {                                    
        if (Input.GetKeyDown (KeyCode.Space))              //當按下鍵盤  "空白建"時
            print ("space key was pressed");           //顯示 space key was pressed
}
-------------------------
var Speed:float;          //宣告跑數為變數

function Update () {
    var Speed=20;       //宣告跑數=20
    if (Input.GetKey (KeyCode.D)) {                //當按下D時做動作.放開則不做
       this.transform.Translate(Speed*Time.deltaTime,0.0,0.0,Space.Self);     //設定水平  對其自己
    }

---------------------------------

註解.動作=  本身可以旋轉.並沿著旋轉方向前進

    var speed : float = 10.0;                         //宣告跑速度為變數且等於10
    var rotationSpeed : float = 100.0;                //宣告旋轉速度為變數解等於10
    function Update () {
        
        var translation : float = Input.GetAxis ("Vertical") * speed;
        var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
        
        // Make it move 10 meters per second instead of 10 meters per frame...
        translation *= Time.deltaTime;
        rotation *= Time.deltaTime;
        
        // Move translation along the object's z-axis         //翻?移?沿?象的z?
        transform.Translate (0, 0, translation);
        // Rotate around our y-axis                           // ??我?的y?旋?
        transform.Rotate (0, rotation, 0);
    }
---------------------------------
function OnMouseDown () {                  //當滑鼠按下      

   Application.LoadLevel(2);               //載入場景 2  ((場景只能用內建代號
}
---------------------------------
function OnMouseDown () {                               //當滑鼠按下
    transform.position = Vector3( 10, 10, 10);           //瞬間移動到指定位子  (10 10 10)
}
-------------------------------
function OnTriggerEnter (other : Collider) {            // 當物體碰撞   ((other被碰撞物
        Destroy(other.gameObject);              //毀掉一切
    }
-------------------------------
function OnGUI() {                                             //把她丟入  GAMEOBJECT 空物件即可
if (GUI.Button(Rect(490,20,150,50),"START"))                   //生成一個文字案件 (Rect(位子) , "名稱")
            {                                      //要誇號
            Application.LoadLevel(1);              //載入場景  場景代號不確定
        }                                              //要誇號
    }
-------------------------------


  if(Input.GetKey(KeyCode.Mouse0)){             // 當按下滑鼠左鍵 (0 __  代表左鍵)
                         
}



-----------------
http://bbs.9ria.com/forum-271-2.html             腳本範例
--------------------------------------
function Update () {
var hit : RaycastHit;                                                     //設定碰撞
 if(Physics.Raycast(transform.position,transform.forward,hit,100)){       //呼叫碰撞ray (原點-方向-碰撞-ray 長度)
  if(hit.transform.name == "Cube01"){                                     // 如果碰撞變數名稱是""
     print("hi");
  }
 }
}------------------------------
function Update () {

var aa = GameObject.Find("play");
var bb = GameObject.Find("Cube");

var dis : float=Vector3.Distance(aa.transform.position, bb.transform.position);              // 距離判斷觸發
if(dis > 100){
print("get");
}
}------------------------------------

Application.OpenURL ("http://game.ceeger.com/");                                          //連結網頁
-----------------------------------


arrow
arrow
    全站熱搜

    lkj2000168 發表在 痞客邦 留言(0) 人氣()