facebook twitter hatena line email

Unity/おすすめアセット/紙吹雪

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

kayacの紙吹雪

  1. https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる
  2. prefab/Confettiをシーンに置く
  3. Confetti.csを空オブジェクトにAddComponentする

公式:https://techblog.kayac.com/unity-physically-simulated-confetti

5秒ごとに紙吹雪花火サンプル(Dotween必須)

    void Confetti()
    {
        GameObject prefab = playRunView.confettiPrefab;
        GameObject confettiObject = Instantiate(prefab, Vector3.zero, Quaternion.identity);
        confettiObject.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f);
        Vector3 initPosition = new Vector3(82, 5, 1);
        // Vector3 initPosition = new Vector3(0, 5, 1);
        confettiObject.GetComponent<Confetti>().PieceWidth = 3f;
        confettiObject.GetComponent<Confetti>().PieceLength = 3f;
        confettiObject.transform.localPosition = new Vector3(initPosition.x, 0, initPosition.z);

        var sequence = DOTween.Sequence();
        sequence.Append(confettiObject.transform.DOLocalMoveY(initPosition.y, 0.5f));
        sequence.Append(confettiObject.transform.DOLocalMoveY(initPosition.y * 0.8f, 5f));
        sequence.Play().OnComplete(() =>
        {
            confettiObject.GetComponent<Confetti>().EmitPiecePerSecond = 0;
            Destroy(confettiObject, 5f);
            Confetti();
        });
    }

confetti-fx-2

https://assetstore.unity.com/packages/vfx/particles/confetti-fx-2-170027?aid=1101lkNYi&utm_campaign=unity_affiliate&utm_medium=affiliate&utm_source=partnerize-linkmaker