1、簡單粒子製作
1、按參考資源要求,製作一個粒子系統,參考資源
(1)打開unity3d,按照參考資源,將給的資源打包import進項目中,我們先創建光暈,粒子系統GuangQiu,對GuangQiu進行調參。
具體參數如下圖所示:
設置完GuangQiu後我們再創建一個粒子系統來對光暈進行修飾效果。
整個的設置如圖所示:
接下來我們開始模擬星光,創建粒子系統XinGuang,繼續進行設置:
這樣我們的第一個粒子系統就做好了,這裏我們並沒有完全按照教程所給的設置,是因爲我在使用了其給的設置後發現沒有達到預期效果,所以這裏我後面進行了不同的調整。
2、使用 3.3 節介紹,用代碼控制使之在不同場景下效果不一樣。
在3.3中我們可以看到一個 對汽車尾氣進行模擬的例子,同時下面也給出了參考的代碼段,我們按照指示設計出兩個場景。
第一個場景是在模擬粒子坍縮:
具體代碼如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class midlight : MonoBehaviour {
ParticleSystem midLight;
float size = 2000f;
// Use this for initialization
void Start()
{
midLight = GetComponent<ParticleSystem>();
}
// Update is called once per frame
void Update()
{
size = size * 0.99f;
var main = midLight.main;
main.startSize = size;
}
}
第二個場景
粒子系統逐漸消失/消亡
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class elimnation : MonoBehaviour
{
ParticleSystem elimnate;
public float size = 4f;
void Start()
{
elimnate = GetComponent<ParticleSystem>();
}
// Update is called once per frame
void Update()
{
size = size * 0.99f;
var main = elimnate.main;
main.startSize = size;
}
}
我的github:Github