渲染
gameObject.GetComponent<Renderer>().material.color = Color.red;
重要事件
OnMouseDown() 鼠標(biāo)點(diǎn)擊
OnMouseOver() 鼠標(biāo)滑入
OnMouseExit() 鼠標(biāo)滑出
FixedUpdate() 物理計(jì)算
Awake()
Reset()
物理材質(zhì)
bounciness 彈力[0,1]
消息推送
- SendMessage
作用:調(diào)用一個(gè)對象的指定函數(shù)蛇摸,這個(gè)函數(shù)可以是公有的也可以是私有的 - SendMessageUpwards
作用:推送給本對象及其所有父對象 - BroadcastMessage
作用:推送給本對象及其所有子對象
CharacterController
CollisonFlags.Above
CollisonFlags.Below
CollisonFlags.Sides
CollisonFlags.None
//頂部碰撞
cc.Move(V3) & CollisonFlags.Above
OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit hit){
if (hit.gameObject.name == "gun1" && flag){
go=hit.gameObject;
go.GetComponent<Animation>().Play("load1");
flag = false;
}
}
光線投射
if (Physics.Raycast(transform.position,transform.forward,out _hit,3f)){
if (_hit.collider.gameObject.name=="gun1"){
print("gun1");
}
}