- Home /
shuirken particle system and colliders2d
hi , ive read around that it is not possible to detect collisions from particlesystem (shuriken) with colliders2d, i was wondering if it is posible to use something like collider2D.bounds.Contains, and detect if this collider2d, contains a position of any of the particles generated by the particlesystem. any help is appreciated ty
I don't see why not. Use GetParticles() to grab the particle array and loop over it to check against the bounds. Alternatively, have a 3D box collider in addition to the 2D collider, specifically for this purpose. Frankly that'd probably be more performant than rolling your own collision response system.
i have some code but the list is not being filled, its as follows
ParticleList = new ParticleSystem.Particle[particlesys.particleCount];
particlesys.GetParticles(ParticleList);
Debug.Log(ParticleList.Length);
for(int i = 0; i < ParticleList.Length; ++i)
{
Debug.Log(ParticleList);
if(collider2D.bounds.Contains(ParticleList[i].position))
{
Debug.Log("go crazy);
}
}
So line 3's Debug prints zero? This code looks alright to me, except line 6 which wants to log the array itself.
exactly , prints 0 nothing in array so the for loop never does anything
Are you quite sure the particle system is the correct reference? Try printing particlesys.particleCount and ensure it's non-zero.
Your answer
Follow this Question
Related Questions
Change particles alpha / sharedMaterial 0 Answers
How is Limit Velocity Over Lifetime calculated? 0 Answers
How to destroy live particle in Shuriken 1 Answer
Particle collision problem 0 Answers