1. 程式人生 > >關於Unity中粒子效果的使用

關於Unity中粒子效果的使用

xtu 渲染器 ani key -- 編輯 pin nod animation

粒子效果
1: 遊戲中會有很炫酷的特效,比如爆炸,水花,火焰等;
2: unity提供粒子編輯器,方便特效人員來開發很炫酷的特效;
3.粒子效果一般有專門的粒子特效師來做,我們只需要拿來用就好了,很多參數沒必要掌握。

Particle System組件面板

1: 粒子系統主體;
2: 噴射(Emission);
3: 形態(shape);
4: 生命周期內的速度偏移(velocity over lifetime);
5: 生命周期內的限制速度(limit velocity over lifetime);
6: 生命周期內的受力偏移(Force velocity over lifetime);
7: 生命周期內的顏色(Color velocity over lifetime);
8:顏色隨速度的變化(Color by Speed);
9: 生命周期內的大小(Size over lifetime);
10: 大小隨速度變化(Size by speed);
11: 生命周期內的轉速(Rotation over lifetime);
12: 角速度隨速度變化(Rotation by Speed);
13: 外部作用力(External Forces)
14: 碰撞(Collision)
15: 子發射系統(Sub Eimitters);
16: 紋理層動畫(Texture Sheet Animation);
17: 渲染器(Render);

Node屬性板

1: Duration: 粒子噴射周期;
2: Looping: 是否循環噴射;
3: Prewarm: 預熱(Loop狀態下預產生下一周期的粒子);
4: StartDelay: 粒子噴射延遲,Prewarm無法延遲;
5: Start Lifetime: 粒子生命周期;
6: Start speed: 粒子噴射速度;
7: Start Rotation: 粒子大小;
8: Start Color: 粒子顏色;
9: Gravity Modifier: 相對與重力加速的的重力密度(縮放比);
10: Inherit Velocity: 新生粒子的繼承速度;
11: Simulation Space: 粒子系統的模擬空間;
12: Play On Awake: 是否在加載的時候播放;


13: MaxParticles: 一周內發射的例子數,多與此數目停止發射

Shape屬性板

1:決定了例子系統噴射的範圍;
2: 主要的形狀有:
球體(Sphere) 半球體(HemiSphere)
圓錐體 Cone, 盒子(Box)
網格(Mesh) 環形(Cricle) 邊線(Edge)

Renderer屬性板

創建步驟

1: 創建Unity項目

2: 創建一個粒子

(1) GameObject--> Particle System;

(2) 創建一個節點-->添加一個ParticleSystem組件;

導入和使用

1: 創建Unity項目

2.import package---->Cuostom package---->partycle.unitypackage

3.把預制體Tree拖進節點視圖中

4.創建一個腳本test_particle掛載到Tree節點下,通過代碼控制粒子屬性和進行操作

5.test_particle腳本內容如下:

using UnityEngine;
using System.Collections;

public class test_particle : MonoBehaviour {
    ParticleSystem ps;
    // Use this for initialization
    void Start () {
        this.ps = this.GetComponent<ParticleSystem>();
        Debug.Log(this.ps.duration);
        this.Invoke("play_particle", 5);
    }

    void play_particle() {
        this.ps.Play();
    }

    // Update is called once per frame
    void Update () {
        if (Input.GetKeyDown(KeyCode.Space)) {
            if (this.ps.isPaused)
            {
                this.ps.Play();
            }
            else {
                this.ps.Pause();
            }
        }
        if (Input.GetKeyDown(KeyCode.S)) {
            if (this.ps.isStopped) {
                this.ps.Play();
            }
            else {
                this.ps.Stop();
            }
        }
    }
}

關於Unity中粒子效果的使用