- var particlesPerFixedUpdate = 1;
- //声明三个料子发射器
- var rain : ParticleEmitter;
- var ripple : ParticleEmitter;
- var splash : ParticleEmitter;
- private var tempParticles = 0;
- /*function FixedUpdate ()
- /{
- tempParticles = particlesPerFixedUpdate;
- while(tempParticles > 0)
- {
- Rain();
- tempParticles --;
- }
- }
- */// I don't understand why we need the stuff above?
- //执行下雨函数
- function FixedUpdate ()
- {
- Rain();
- }
- //声明下雨函数
- function Rain ()
- {
- //=====默认设置下,三个料子发射器处于关闭状态,并未发射料子。
- //在xz平面上取得随机坐标点,y为20
- pos = Vector3(Random.Range(-5.00, 5.00), 20 ,Random.Range(-5.00, 5.00));
- //根据rain发射器的最大最小值区间取得随机值,生命值,开始发射料子。
- size = Random.Range(rain.minSize, rain.maxSize);
- lifetime = Random.Range(rain.minEnergy, rain.maxEnergy);
- //料子发射器的一方法 。function Emit (pos : Vector3, velocity : Vector3, size : float, energy : float, color : Color) : void
- rain.Emit(pos, rain.worldVelocity, size, lifetime, Color.white);
- //等待1秒,改变y坐标,并设置相应的尺寸和生命时间,水波纹及小水花两个料子发射器开始发射料子。
- yield WaitForSeconds(1);
- pos.y = splash.transform.position.y;
- size = Random.Range(ripple.minSize, ripple.maxSize);
- lifetime = Random.Range(ripple.minEnergy, ripple.maxEnergy);
- ripple.Emit(pos, ripple.worldVelocity, size, lifetime, Color.white);
- size = Random.Range(splash.minSize, splash.maxSize);
- lifetime = Random.Range(splash.minEnergy, splash.maxEnergy);
- splash.Emit(pos, splash.worldVelocity, size, lifetime, Color.white);
- }
- 本文来自:http://blog.csdn.net/zhulinpptor/article/details/5882969
Unity3d 雨滴落水脚本
最新推荐文章于 2021-08-29 23:24:01 发布