以下均为来自中国大学mooc 游戏引擎原理及应用时的学习笔记,不含商用,仅供学习交流使用,如果侵权请联系作者删除。


文章目录

  • 4.1 视频播放
  • 4.2 粒子系统
  • 4.3 后处理效果


4.1 视频播放

unity UI电路特效 unity特效教程_游戏


unity UI电路特效 unity特效教程_游戏_02

首先将摄像机调整成如图所示

unity UI电路特效 unity特效教程_游戏开发_03


unity UI电路特效 unity特效教程_游戏_04


然后调整为平行投影然后给plane添加一个组件 video player

unity UI电路特效 unity特效教程_游戏开发_05

然后接下来把视频文件拖拽到video player的video clip下 就可以播放了

如果我们想通过空格键来控制是否播放 我们可以这样:
插入以下代码

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


public class VideoControl : MonoBehaviour
{
    VideoPlayer vp;
    // Start is called before the first frame update
    void Start()
    {
        vp = GetComponent<VideoPlayer>();

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (vp.isPlaying)//注意 isplaying是个成员变量
            {
                vp.Pause();
            }
            else
            {
                vp.Play();
            }
        }
    }
}

unity UI电路特效 unity特效教程_unity_06


这个选项是一开始的时候就进行播放的选项

4.2 粒子系统

新建一个粒子

unity UI电路特效 unity特效教程_unity3d_07


然后新建一个材质,并将着色器选为Particles的v

unity UI电路特效 unity特效教程_游戏开发_08


选择这个

unity UI电路特效 unity特效教程_游戏开发_09


然后设置这个

unity UI电路特效 unity特效教程_unity3d_10


unity UI电路特效 unity特效教程_游戏_11

由于火焰是8行4列 所以进行如图所示的设置

unity UI电路特效 unity特效教程_unity3d_12

unity UI电路特效 unity特效教程_unity_13


cycles指的是粒子的生命周期 动画序列的重复次数我们设置为3

unity UI电路特效 unity特效教程_unity3d_14


unity UI电路特效 unity特效教程_游戏_15

unity UI电路特效 unity特效教程_游戏开发_16


unity UI电路特效 unity特效教程_unity_17


unity UI电路特效 unity特效教程_游戏开发_18


每秒发散出多少粒子

这个火焰不需要特定的形状 因此把shape取消选中

lifetime是指生存时间 将生存时间随机可以更好的模拟火焰

unity UI电路特效 unity特效教程_游戏开发_19

这个火焰从无到有再到无:在color over lifetime里面实现

unity UI电路特效 unity特效教程_unity UI电路特效_20


unity UI电路特效 unity特效教程_unity UI电路特效_21


这个billboard也会影响火焰的形状火焰模拟完了之后 接下来为他创建一个子物体粒子系统

名为smoke

unity UI电路特效 unity特效教程_游戏_22

然后创造一个材质

unity UI电路特效 unity特效教程_游戏_23


unity UI电路特效 unity特效教程_游戏开发_24


选中摄像机然后按ctrl+shift+f便可以使摄像头对齐然后我们调整这个参数 可以调整产生的烟雾的多少

unity UI电路特效 unity特效教程_unity3d_25


unity UI电路特效 unity特效教程_unity3d_26


还可以调整烟雾的形状

unity UI电路特效 unity特效教程_unity3d_27


unity UI电路特效 unity特效教程_unity3d_28


上面调整透明的变化

下面调整颜色的变化多个粒子出现在一起时候的出现顺序

unity UI电路特效 unity特效教程_unity_29


unity UI电路特效 unity特效教程_unity UI电路特效_30


sorting fudge指的是如果这个粒子系统跟其他带有透明通道的物体有重叠关系的话,绘制的前后顺序,越低的值代表粒子系统越有可能低于其他物体的前面我们希望这个烟雾随着时间的增长 烟雾的大小会越来越大:

unity UI电路特效 unity特效教程_unity_31


unity UI电路特效 unity特效教程_unity3d_32


duration是粒子系统一个循环的时长,lifetime是单个粒子持续时长

4.3 后处理效果

unity UI电路特效 unity特效教程_游戏开发_33


unity UI电路特效 unity特效教程_unity UI电路特效_34


unity UI电路特效 unity特效教程_unity UI电路特效_35


unity UI电路特效 unity特效教程_游戏开发_36

unity UI电路特效 unity特效教程_unity_37


unity UI电路特效 unity特效教程_unity3d_38


右边的这个图渲染出了一个懒洋洋的效果

unity UI电路特效 unity特效教程_unity3d_39


unity UI电路特效 unity特效教程_unity_40