I am creating a forward scrolling shooter, and I want to have a very, very, large number of bullets on the screen at once. Should I use objects, or are particles the better solution?
You will be fine using GameObjects (and it’ll offer more control than using particles) but look into Object Pooling so you’re not thrashing the garbage collection.
Hey thanks, this isn’t a half-bad idea.
It’s working great until I get about 1000 simple bullets on screen at once, then the lag begins. Is there any way to counter this?
If it’s a typical bullet hell shmup I’d expect that the bullets don’t ever need to collide with each other. If that is the case put them on a layer called something like EnemyBullets and then go to Edit > Project Settings > Physics and make sure that EnemyBullets do not collide against EnemyBullets. I can’t be sure if that will help but it makes sense to do so before anything else.
Alternatively, if this is a purely 2D play area you might find it quicker to cast off the Unity collision system of rigidbodies and simply perform the movement collision checks yourself. Though I can’t vouch for the actual validity of that. It’s just an thought.
There’s probably a few more things that others might be able to suggest that’ll help.
I already turned off physics for self check, however I never considered all of those colliders doing collision checks. I will take off the colliders completely and see what happens. Unfortunately, I am working in 3D.
Edit: Even removing all collision components, I am still capping pretty hard around 700 bullets on the screen at once. These are simple planes with a simple texture on them. The texture is around 250x250. Could that be the issue?