物理材質(zhì)(Physic Material):
項目視圖(project)右擊? Create - Physic Material ? ?選擇創(chuàng)建

屬性依次為:動態(tài)摩擦力? 靜態(tài)摩擦力? ? 反彈力? ? 組合摩擦力(取平均值、取最小值、取乘積值、取最大值)組合彈力(取平均值、取最小值、取乘積值、取最大值)
使用方法: ?直接把設(shè)置好的物理材質(zhì)拖進(jìn)去就行了

射線Ray:
射線類Ray組成部分、起點(0rigin)方向(direction)
//實例化一條射線
Camera.main主攝像機(jī) ? ? ? ? ? ? ScreenPointToRay將屏幕上的一個點轉(zhuǎn)換成射線
Input.mousePosition獲取鼠標(biāo)坐標(biāo)
Ray ??r = ?Camera.main.ScreenPointToRay(Input.mousePosition);
Raycast發(fā)射物理射線返回一個碰撞檢測對象RaycastHit【參數(shù)有 ?起點 ?方向 ?距離】
Physics物理學(xué) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Physics.Raycast(r, 1000)
raycastAll發(fā)射物理射線,返回所有碰撞檢測對象RaycastHit
用來描述射線射到的物體
RaycastHit hit;
屬性collider碰撞物體的Collider組件point碰撞點坐標(biāo)
.point可以獲取射線射到的點的世界坐標(biāo)
世界坐標(biāo)器
本地坐標(biāo)器
攝像機(jī)坐標(biāo)系:
屏幕坐標(biāo)系:(ScreenPoint)
視圖坐標(biāo)系:(ViewPoint)
示例:
void RayCastTest()
{
//實例化一條射線
Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
//用來描述射線射到的物體
RaycastHit hit;
//
if(Physics.Raycast(r, out hit,100)){
//打印射中物體的名字
Debug.Log(hit.transform.name);
if (hit.transform.name == "Plane")
{
//.point可以獲取射線射到的點的世界坐標(biāo)
//transform.position = hit.point + new Vector3(0,0.5f,0);
transform.position = Vector3.Lerp(transform.position, hit.point + new Vector3(0, 0.5f, 0), Time.deltaTime * 5);
}
}