3D作業8--粒子系統

作業要求

  • 簡單粒子製作

    按參考資源要求,製作一個粒子系統,參考資源
    使用 3.3 節介紹,用代碼控制使之在不同場景下效果不一樣

參考博客

https://www.cnblogs.com/CaomaoUnity3d/p/5983730.html

https://blog.csdn.net/qq_36312878/article/details/80492125
其中,後一篇博客將粒子系統的各個參數均羅列了出來,這裏就不照搬了。

實現過程

生成ParticleSystem

創建一個空項目,添加ParticleSystem的組件,掛上材料,調節參數。

整體粒子包含:

  1. 中間光的模擬(midLight)
  2. 光暈的模擬(halo)
  3. 周圍星光的模擬(shining)

中間光的模擬(midLight)

(因爲我個人比較喜歡藍色,這裏就用的藍色的光啦)
在這裏插入圖片描述

光暈的模擬(halo)

在這裏插入圖片描述

周圍星光的模擬(shining)

在這裏插入圖片描述
三者都是創建在空對象的下面,因爲是粒子的整體部分,所以把它當做粒子的父類節點。
中間部分的粒子不會移動,所以Speed設置爲0,粒子的Shape可以爲Box或者Sphere,因爲主要目的是讓光暈填充完這個粒子(顯的飽滿)。

代碼控制

控制功能

模擬下礦洞,或者調入深淵中,頭上的太陽模擬

中間部分的控制

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class midLightChange : MonoBehaviour {

    ParticleSystem exhaust;
    float size = 2f;

    // Use this for initialization
    void Start()
    {
        exhaust = GetComponent<ParticleSystem>();
    }

    // Update is called once per frame
    void Update()
    {
        size = size * 0.999f;
        var main = exhaust.main;
        main.startSize = size;
    }

}

光暈控制

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class haloChange : MonoBehaviour {
    ParticleSystem exhaust;
    float size = 5f;

    // Use this for initialization
    void Start()
    {
        exhaust = GetComponent<ParticleSystem>();
    }

    // Update is called once per frame
    void Update()
    {
        size = size * 0.999f;
        var main = exhaust.main;
        main.startSize = size;
    }
}

項目地址

詳見我的GitHub

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章