Unity3d学习笔记(一)Particle Layer

今天简单看了下一个比较老的Partical Tutorial的例子,感觉Unity的粒子系统还是较为先进的,以前GB连长条形粒子都做不到,真心痛苦……但GB可以直接在Max里面预览效果,而且可以使用Max本身的粒子系统和动画工具,这样的设计思路即使现在看来也是非常先进的,可惜换了下家之后一直不死不活……商业化的恶果,不提了。

废话说完,接下来记笔记:

在使用旧有的Legacy Particle System时,Particle Renderer的Materials Size参数可以设置成大于1使得同一个粒子系统使用多种材质,但是似乎排序是id越低的排在越后面,比如Element 0就排在Element 1的下面,这个和新的Shuriken粒子系统里面的Sorting Fudge正好反过来,后者是数字越低排在越前(这里的前后都是指在摄像机空间内的前后关系)

旧有的Legacy Particle System当多个粒子系统重合的时候,自动排序会变得混乱,这时候可以采用一个Particle Layer的强制排序脚本挂在物体上,是个javascript,不知道编译之后效率如何,代码如下:

// ParticleLayer.js

 

var layerhieght = 0.00;

 

private var position : Vector3;

position = transform.localPosition;

 

function Update ()

{

    object = Camera.main.gameObject;

 

    vector = object.transform.position - transform.position;

 

    if(transform.parent && (vector.magnitude > layerhieght || layerhieght < 0.00) ) transform.position = transform.parent.TransformPoint(position) + vector.normalized * layerhieght;

}
To get the script into the project, click on the Create menu in the Project pane and select JavaScript from the menu. Name your script "ParticleLayer" and then open it and paste the code into it. Save it, return to Unity and wait for it to compile. (Shown by a little rotating thing in the lower right corner. With just this script it should be almost instant) Once it is done, drag the script from the Project pane to the Hierarchy and onto your fire particle emitter that is a child of "Fire Group". Then select the object you just dragged the script onto and set Layer Height to 0.5. This will make the fire always 0.5 meters closer to the camera then it normally would be.

参数只要大于0估计就差不多了,不过对于烟雾和火焰的制作,烟雾和火焰发射器之间的间距肯定要大于这个数值,不然从顶上或者底下看起来就不对了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值