1.Instantiate
原型:public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);
作用:生成对象实例。可用于新生成子弹/炮弹/物体,也可用于刷新敌人
注:
1)该函数返回值在monodevelop中查看返回值为GameObject,官方api手册中为Object
2)该函数共有4个不同的版本对应不同的传参,以上为最常用版本
3)获取新生成的物体的属性/组件时,需要定义变量储存以便访问,如:
Game Object p = Instantiate ();
Rigidbody m = p.GetComponent<Rigidbody> ();
2.位移函数
(1)transform.Translate
原型:public void Translate(Vector3 translation, Space relativeTo = Space.Self);
作用:使某物在三维世界中“瞬移”
例:transform.Translate (new Vector3 (0, 0, 1) * moveSpeed * Time.deltaTime);
注:参数为矢量,必须带方向,可加速度变量乘在参数内
(2)velocity(对于刚体)
原型:public Vector3 velocity;
例:r.velocity = shootPoint.forward * shootPower;
注:赋值刚体速度,同样也为矢量,适用物理定律
3.transform.RotateAround
原型:public void RotateAround(Vector3 point, Vector3 axis, float angle);
作用:使某物绕另一物体的哪一跟轴旋转
例:transform.RotateAround (center.GetComponent<Transform>().position,Vector3.up,-70 * Time.deltaTime);
使transform绕着center的y轴旋转,速度为70
4.Physics.OverlapSphere
原型:
Destroy (se,delayClearExplosion); //在delayClearExplosion秒后删除se