// Update is called once per frame void FixedUpdate() { foreach (Particle2DLink it in linkList) { it.CreateContacts(particleList[it.id1], particleList[it.id2]); } ContactResolver resolver = new ContactResolver(); resolver.resolveContacts(contacts); for (int i = 0; i < particleList.Count; i++) { if (particleList[i] != null) { if (Vector2.Distance(particleList[i].transform.position, target.transform.position) <= .5) { particleList[i].GetComponent <Particle2D>().Remove(); target.GetComponent <Target>().GetHit(); } Integrator.Integrate(particleList[i]); } } foreach (int itr in destroyList) { Destroy(particleList[itr]); particleList[itr] = null; } destroyList.Clear(); }
// Update is called once per frame void FixedUpdate() { foreach (Particle2DLink it in linkList) { it.CreateContacts(particleManager.GetParticle(it.id1), particleManager.GetParticle(it.id2), contactPrefab); } resolver.resolveContacts(contacts); particleManager.ParticleUpdate(); for (int i = 0; i < particleManager.GetCount(); i++) { if (particleManager.GetParticle(i) != null) { if (Vector2.Distance(particleManager.GetParticle(i).transform.position, target.transform.position) <= .5) { particleManager.GetParticle(i).GetComponent <Particle2D>().Remove(); target.GetComponent <Target>().GetHit(); } Integrator.Integrate(particleManager.GetParticle(i)); } } foreach (int itr in destroyList) { particleManager.RemoveParticle(itr); } destroyList.Clear(); frame += .016f; if (frame >= .25) { MakeRandomProjectile(randomParticle); frame = 0; } }