让物体沿x轴移动:transform.Translate (new Vector3 (1, 0, 0));
//x值为正,沿x正半轴移动;x值为负,沿x负半轴移动
让物体沿y轴移动:transform.Translate (new Vector3 (0, 1, 0));
//y值为正,沿y正半轴移动;y值为负,沿y负半轴移动
让物体沿z轴移动:transform.Translate (new Vector3 (0, 0, 1));
//z值为正,沿z正半轴移动;z值为负,沿z负半轴移动
让物体沿前方移动:transform.Translate (new Vector3 (forward)); //new Vector3三维
让物体沿后方移动:transform.Translate (new Vector3 (back));
让物体沿左方移动:transform.Translate (new Vector3 (left));
让物体沿右方移动:transform.Translate (new Vector3 (right));
让物体沿上方移动:transform.Translate (new Vector3 (up));
让物体沿下方移动:transform.Translate (new Vector3 (down));
让物体沿z轴旋转: transform.Rotate (new Vector3 (0, 0,1));
让物体沿z轴增长: transform.localScale+=(new Vector3 (0, 0, 0.1f));
创建对象
GameObject cube=GameObject.CreatePrimitive(PrimitiveType.Cube);
克隆对象
GameObject obj=(GameObject)Instantiate(cube);
销毁对象
Destroy(obj,1);//1是在一秒后销毁对象
1、//给游戏物体添加名为FoobarScript的脚本
GameObject.AddComponent ("FoobarScript");
2、//给游戏物体添加刚体
Rigidbody rb = GameObject.AddComponent ("Rigidbody");
3、//给游戏物体添加球体碰撞器
SphereCollider sc=GameObject.AddComponent ("SphereCollider");
常用核心类
1)通过名称来查找:
GameObject player = new GameObject("Player");
GameObject go=GameObject.Find(“Player”);
2)通过tag标签获取单个游戏对象:
GameObject go=GameObject.FindWithTag(“Player”);
GameObject go=GameObject..FindGameObjectWithTag (“Player”);
3)通过游戏标签获取多组游戏对象:
GameObject[] go=GameObject.FindGameObjectsWithTag (“Player”);
Time类
按下A键,游戏物体向左移动;按下D键,游戏物体向右移动
float move_h=0;
if (Input.GetKey (KeyCode.A)) {
move_h-=Time.deltaTime;
}
if (Input.GetKey (KeyCode.D)) {
move_h+=Time.deltaTime; }
transform.Translate(new Vector3(move_h,0,move_v));
以上是数据库的初步了解,如果你有什么不会的话,可以来狗刨学习网上来看看,如果你想在Unity3D上大展手脚的话,可以来狗刨培训与专家咨询。