指令碼生命週期
//每當指令碼被載入時呼叫一次
// 1. 在awake中做一些初始化操作
void awake()
//在第一次呼叫update之前呼叫一次start,即使取消啟用,再啟用也不會再執行
// 3. 在start中做一些初始化操作
void start()
// 5. 在update方法呼叫完之後呼叫
void lateupdate(){} //如重新整理完邏輯操作
// 6. 取消啟用狀態後呼叫
void ondisable(){}
// 7. 腳步被銷毀時呼叫
void ondestroy(){} //如怪物死亡爆東西
// 8. 持續呼叫 - imgui**需要寫在ongui 方法中和ugui,ngui
void ongui()
input
//n引數 0 滑鼠左鍵
//n引數 1 滑鼠右鍵
//n引數 2 滑鼠中建
input.getmousebuttondown(n) //檢測滑鼠按鍵按下事件
gameobject
//gameobject 獲取當前指令碼所掛載的遊戲物件
//一般來說,在屬性檢視中能看到或修改的屬性,我們同樣可以在指令碼中獲取並修改
gameobject屬性如
controller c = gameobject.getcomponent();
light l = game.addcomponent();
gameobject g = gameobject.findgameobjectwithtag(「tagname」);
gameobject gg = gameobject.findwithtag(「tagname」);
gameobject g = gameobject.find(「object name」):
g.name = 「改名」;
gameobject gs = gameobject.findgameobjectwithtag(「object name」);
gameobject.destroy(gameobject,2f);
vector
vector3 v = new vector3();
成員方法:
v.normalize();
vector3 vn = v.normalized;
float l = v.magnitude;
float f = vector.angle(v1,v2);
float f = vector.distance(v1,v2);
float d = vector3.dot (v1,v2);
vector vc = vector3.cross(v1,v2);
transform
//獲取當前指令碼所掛載的遊戲物件身上的transform元件
//transform
//position 屬性 - 世界座標系中的位置
vector3 pos = transform.position;
transform.localposition
transform.rotation
transform.localrotation
vector3 v = transform.localscale;
transform.translate (new vector3(0,1,0));
transform.rotate (vector.up,10f);
transform.eulerangles = new vector(0f,45f,0f);
//獲取/重新指定 當前遊戲物件父物件的transform元件
transform.parent;
transform.root;
transform.find(「name」);
transform.finechild(「name」);
time
time.deltatime
transform.rotate(vector3.up , time.deltatime * 30f);
// 1 - 表示正常時間流逝
// 2- 表示時間流逝加快,是正常速度的兩倍
// 0 - 表示時間停止,遊戲暫停
float ts = time.timescale;
mathf
int i = mathf.abs(-12);
int m = mathf.max(12,15,15,17);
int ni = mathf.min(12,14);
mathf.sin();
mathf.cos();
mathf.pi();
prefab 預設體
例子:vector pos = new vector3 ();
pos.y = 0.5;
pos.z = random.range(-5f,5f);
float angle = random.range.range (0f,360f);
//引數1:預設體
引數2: 建立出的遊戲物件初始位置
instantiate (plagerprefab , pos , quaternion.angleaxis (angle, vector3.up));
gameobject g = instantiate (plagerprefab , pos , quaternion.angleaxis (angle, vector3.up)) as gameobject;
滑鼠事件
必須物體的collider被啟用,否則無法觸發
void onmousedown(){}
void onmousedrag(){}
void onmouseup(){}
void onmouseenter(){}
void onmouseover(){}
void onmouseexit(){}
void onmouseupasbutton
剛體 rigidbody
剛體使用使物體位移和transform同時使物體位移是不對的,只能使用其中乙個
屬性:mass質量
drag空氣阻力
angular drag角阻力(旋轉時受的)
is kinematic 是否使用運動學
rigidbody rb = getcomponent();
//新增力 力的物體上必須有剛體
要有新增**力指令碼的物件才會受影響
rb.addforce(new vector3(0f,10f,0f));
rb.addtorque(new vector3(0f,10f,0f));//y軸施力
rb.addforceatposition(new vector3(0f,10f,0f), new vector(0.5f,0.5f,0.f));
rb.addexplosionforce(1500f, vector.zero,4f);
collider
發生碰撞的條件:
(去碰撞的物體最好要有剛體,否則可能發生穿越,無觸發碰撞 )
//碰撞開始時會呼叫一次
void oncollisionenter (collision other){}
void oncollisionstay (collision other)
trigger
如果collider中的 is trigger選中了,那麼該物體無法使用剛體,但能使用觸發器
觸發器事件條件:
4.進入觸發範圍後不用一定要有相對運動
void ontriggerenter (collider other){}
void ontriggerstay (collider other){}
void ontriggerexit (collider other){}
材質屬性
彈力摩擦力結合情況
friction combine
bounce combine
AI重要基礎知識點
知乎面試官的問題,慢慢更,直到回答了所有問題 過擬合欠擬合 舉幾個例子讓判斷下,順便問問交叉驗證的目的 超引數搜尋方法 earlystopping l1正則和l2正則的做法 正則化背後的思想 順便問問batchnorm covariance shift l1正則產生稀疏解原理 邏輯回歸為何線性模型 ...
基礎知識點
1 inline block布局 2 table布局 3 justify的末行不對齊 4 兩個圖示之間有空格 換行 5 背景中的的 路徑的 全部斜槓都為 不是 命令列下的這種 doctype html html head meta charset utf 8 title xx title head ...
erlang基礎知識點
1 變數是不可改變的,必須以首字母大寫開頭 2 字串就是小寫字母,或者單引號引起來的字串 3 賦值可以使用匹配模式 4 資料結構有元組,取值用匹配模式來取值 就能取到x,b的值 5 資料結列表 ss,aa,取值是用 head foot 的形式取值 頭和尾的形式匹配 6 字串只能用雙引號表示 7 函式...