Guest User

Untitled

a guest
May 11th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Unicon 0.76 KB | None | 0 0
  1. #pragma strict
  2.  
  3. public var colorToChange : Color;
  4.  
  5. private var _particleSystem : ParticleSystem;
  6. private var _particles : ParticleSystem.Particle[];
  7.  
  8. public function Start() : void
  9. {
  10.     //_particleSystem = gameObject.GetComponent(ParticleSystem);
  11.     _particles = new ParticleSystem.Particle[1000];
  12. }
  13.  
  14. public function LateUpdate() : void
  15. {
  16.     var count : int = particleSystem.GetParticles(_particles);
  17.    
  18.     print("---");
  19.     print(_particles);
  20.     print(count);
  21.     print(particleSystem.particleCount);
  22.    
  23.     for (var i = 0; i < count; i++)
  24.     {
  25.         var hit : RaycastHit;
  26.         if (Physics.Raycast (_particles[i].position, Vector3.forward, hit))
  27.         {      
  28.             print("particle hit"); 
  29.             _particles[i].color = colorToChange;
  30.         }  
  31.     }
  32.     particleSystem.SetParticles(_particles,count);
  33. }
Add Comment
Please, Sign In to add comment