Quantcast
Viewing all articles
Browse latest Browse all 112

particle array null refrence

I'm just messing around trying to add some external effects to my particles(particle attraction in this case). but it seems my particle array isn't being filled, or something is going wrong when i try to fill it with my particleSystem's getParticles() function. i must be creating the array wrong or trying to fill it incorrectly. can anyone see my problem? #pragma strict var target : Transform; var power = 5.0; var PA: ParticleSystem.Particle[]; var heading:Vector3; function Start () { } function Update () { particleSystem.GetParticles(PA); for(var p in PA) { heading = target.position - p.position; p.velocity += heading.normalized * power; } particleSystem.SetParticles(PA, PA.Length); } error is at the 'for' line: NullReferenceException: Object reference not set to an instance of an object i also tried this for loop, but got the same error: for(var i = 0; i < PA.Length; i++) { heading = target.position - PA[i].position; PA[i].velocity += heading.normalized * power; }

Viewing all articles
Browse latest Browse all 112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>