- Home /
How can I give particles "health"?
I'm making a mobile game that requires 500+ enemies on screen at once. I found that I can get excellent performance by having my enemies as particles and my player bullets as rigidbody colliders.
But, these enemies only have one chance at survival! I tried setting "lifetime loss" on collision to simulate health but the particles lose momentum and seem to change rotation, even though dampen and bounce are set to 0. I would like them to stay their course while they are getting hit.
Help much appreciated!
You can try using the ECS for performance. Basically, ins$$anonymous$$d of assigning a component for each enemies, let a single manager handles updating all of them
https://unity3d.com/learn/tutorials/topics/scripting/introduction-ecs
Thanks, I will look into this if my particle solution fails. Curious to see the performance when colliders are involved.
Answer by richardkettlewell · Apr 21, 2019 at 07:27 PM
Try https://docs.unity3d.com/ScriptReference/ParticleSystem.SetCustomParticleData.html
The example that assigns a unique ID could assign a health value instead.
Thanks for the reply, this is very useful. However, I still need some kind of hit detection system for each particle. The particle trigger module would be good for this but it doesn't allow for prefabs in the Colliders property. I tried iterating through my prefab bullet colliders and adding them to this list but there seems to be a max limit of colliders/it doesn't work for some other reason.
It would be great to have a collision module option that only sends callbacks or a trigger module that allows for collider instances.
Prefabs have no position in the world. You must use an instantiated object.
You’re right that the max collider count is quite low I think.
Yes sorry I meant iterating over my instantiated bullets by adding them to a list and using foreach to add them to the trigger collider when they are instantiated. This works for 3-6 bullets out of 100. It seems I'm in the classic one thing almost works then another thing almost works but no dice.
Your answer
Follow this Question
Related Questions
Problems When Shooting Multiple Enemies round about 4 times 1 Answer
Particle System Collision Problem 0 Answers
Activating Particle Effect on Collision: 1 Answer
World particles collider scriptable? 1 Answer
Projectile Collision help 2 Answers