国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【Unity技巧1】ACT游戲制作擊飛物理效果(DoTween)

2022-07-31 08:15 作者:機智的小草yns  | 我要投稿
  • 1.準(zhǔn)備:

  • 插件:DoTween,NaughtyAttributes

    準(zhǔn)備一個有重力的物體,具備CharacterController和剛體

????public CharacterController cc;
??? public float g=9.8f;

??? private void FixedUpdate()
??? {
??????? cc.Move(g * Time.fixedDeltaTime*Vector3.down);
??? }

剛體配置
重力效果


  • 2.利用DoTween數(shù)值動畫,制作擊飛核心方法DOHit

???????

//高度totalY? 擊退方向horVec

public static Tween DOHit(this CharacterController cc, float totalY, Vector3 horVec,float duration)
??????? {
??????????? Transform tf = cc.transform;

??????????? if (totalY == 0)
??????????? {
??????????????? totalY = 0.1f;
??????????? }

??????????? float time = 0;
??????????? float lastT = 0, deltaT = 0;
??????????? //0 ->1的數(shù)值動畫
??????????? Tween tween = DOTween.To(x => time = x, 0, 1, duration);
??????????? tween.SetEase(Ease.OutQuad);
??????????? //tween.SetLoops(2,LoopType.Yoyo);

??????????? Vector3 targetMove = horVec;
??????????? targetMove.y += totalY; //目標(biāo)移動量

??????????? tween.OnUpdate(() =>
??????????? {
??????????????? deltaT = time - lastT;
??????????????? lastT = time;

??????????????? Vector3 delta = targetMove * deltaT;
??????????????? cc.Move(delta);
??????????? });
??????????? return tween;
??????? }

  • 3.測試和調(diào)用

    ? 傳入高度和擊退方向,調(diào)用DOHit方法就可以了

??? public Vector3 move;
??? public float time = 0.1f;
??? [Button]

??? public void OnMove()
??? {
??????? cc.DOHit(move.y, move, time);
??? }

?繪制按鈕使用的是NaughtyAttributes測試組件

連續(xù)點擊就可以看出效果

擊飛效果
  • 最終效果

應(yīng)用到游戲內(nèi) ,加上人物動畫,調(diào)整力度和重力后的效果

  • 補充

    1.DoTween的曲線數(shù)值很好用,使用DOVirtual.EasedValue可以獲取動畫曲線上的點

    y= DOVirtual.EasedValue(0, 1, x , Ease.OutQuad)


  • 其次是將動畫循環(huán)設(shè)置Yoyo, 那么則可以在不使用重力的情況下,追加下落動畫

    tween.SetLoops(2,LoopType.Yoyo);

常用曲線

更多曲線: https://github.com/smartgrass/ReadMeImgs/blob/main/MainPng/DoTweenEase.png

2.NaughtyAttributes--編輯器擴展繪制插件

https://github.com/dbrizov/NaughtyAttributes

【Unity技巧1】ACT游戲制作擊飛物理效果(DoTween)的評論 (共 條)

分享到微博請遵守國家法律
汤原县| 舞钢市| 鄂托克前旗| 大化| 临澧县| 乾安县| 莆田市| 荔浦县| 太仆寺旗| 宜兴市| 兰西县| 普定县| 灵武市| 平利县| 澄城县| 龙川县| 晴隆县| 大足县| 卢氏县| 楚雄市| 泸州市| 偃师市| 濮阳市| 平乐县| 汉阴县| 开封县| 疏勒县| 信宜市| 崇州市| 女性| 墨竹工卡县| 中牟县| 福清市| 镇宁| 修武县| 罗山县| 濮阳市| 赤壁市| 依安县| 宁南县| 绥中县|