Advertisement
infinite_ammo

TestParticles.cs

May 25th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TestParticles : MonoBehaviour
  5. {
  6.     public ParticleAttractor[] particleAttractors;
  7.     ParticleSystem.Particle[] particles = new ParticleSystem.Particle[1000];
  8.  
  9.     void Update()
  10.     {
  11.  
  12.         int length = particleSystem.GetParticles(particles);
  13.         for (int i = 0; i < length; i++)
  14.         {
  15.             for (int j = 0; j < particleAttractors.Length; j++)
  16.             {
  17.                 Vector3 diff = particleAttractors[j].transform.position - particles[i].position;
  18.                 particles[i].velocity += diff.normalized * particleAttractors[j].strength * Time.deltaTime;
  19.             }
  20.         }
  21.         particleSystem.SetParticles(particles, length);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement