方向的描述,欧拉角和四元数
//旋转:欧拉角、四元数
//欧拉角也用Vector3表示。
//沿y轴旋转30°
Vector3 rotate = new Vector3(0,30,0)
//无旋转四元数
Quaternion quaternion = Quaternion.identity
//通过欧拉角创建四元数
quaternion = Quaternion.Euler(rotate)
//四元数转换成欧拉角
rotate = quaternion.eulerAngles
//看向一个物体
quaternion = Quaternion.LookRotation(new Vector3(0,0,0))
常用调试方法
Debug.Log();
Debug.LogWarning("test2");
Debug.LogError();
Debug.DrawLine(Vector3.zero,Vector3.one[,Color.color]);
Debug.DrawRay(Vector3.zero,Vector3.up[,Color.color]);
游戏物体GameObject的使用方法
public GameObject Cube;
GameObject go = this.gameObject;
Debug.Log(go.name);
或
Debug.Log(gameObject,name);
Debug.Log(gameObject.tag);
Debug.Log(gameObject.layer);
Debug.Log(Cube.activeInHierrachy);
Debug.Log(Cube.activeSelf);
Debug.Log.(transform.position);
BoxCollider bc = GetComponent<BoxCollider>();
GetComponentInChildren<CapsuleCollider>(bc);
GetComponentInParent<BoxCollider>();
Cube.AddComponent<AudioSource>();
GameObject game = GameObject.Find("GameObjectName");
Debug.Log(game.name);
GameObject = GameObject.FindWithTag("Enemy");