1. 怎樣從A動作換到B動作。
從 jump 到 walk (from 128)
2. Animation Event: 在某個Sprite call a funtion。
****
一、介紹 Animation State
1. In the animator -> 在要的State 右鍵 make transition -> 點下一個state
2. Animation Event:
2.1 點time line 中的 Event icon可以看到下圖:
Function: 要執行的函數。 其他為傳入的參數(只限1個)。
二、改變 Animation State
滿足條件實在改變state。例如: 有敵人時攻擊,沒有時等待。
1. Has Exit Time:需不需要有特定的結束時間,例如等動作完全結束。( In the transition line )
1.1 關掉,因為想要馬上切換動作。例如: 攻擊state -> walk state,不須等動作結束就切換。
1.2 勾選,要等動作結束在換動作。例如: 跳 state -> walk state,等動作"跳完"在切換。
2. 在animator中增加條件參數:
3. 在transition line中增加條件,例如在Idle->attack的transition line中,加入條件如下:(當IsAttacking為true時,從Idle state轉為 attack state)
4. use the code below to change the condition.
4.1 For boll:
GetComponent<Animator>().SetBool("IsAttacking", true);
4.2 For Trigger:
GetComponent<Animator>().SetTrigger("jumpTrigger");