hi - I’m curious as to how you would approach the gunfire for a hectic shooter like Raiden or RType?
So what are the challenges?
Performance: being able to render perhaps hundreds of bullets/lasers on screen at once at acceptable framerates on mobile devices (lets say 25fps min).
Hit Detection: knowing which bullet hit what.
For performance, I had thought of having a texture page that includes several bullet/laser icons and managing every bullet through a particle emitter manually. This way, they could be rendered in one go and I could force an animated frame to represent the different bullets.
Does this seem feasable?
Detection is where I’m worried - if there are hundred of these bullets going on, I’m worried having to use things like SphereChecks… you could simplify the problem to 2D and just use simple ‘point is in rectangle’ checks? But is there a better way?
Thoughts?
I’m designing a similar game, another general Danmaku game.
For bullets I’m actually using projectiles, as the processing for those is less then the processing for particles.
As for the collisions, im currently using planes for EVERYTHING, planes with alphas, and as shooters in this genre are generally pretty damned fast, I’ve taken to using sphere and box colliders for collisions.
It’s not 100% needed to have 100% accuracy collision wise, so long as at least most of the enemy is collidable, using simple primitive colliders is also pretty simple geometry, so that of course also helps with the processing overhead.
Another good thing to do is to Pool both you bullets and your enemies instead of destroying and instantiating them each time.
Though I’m stuck on creating an A.I for the enemies so unfortunately I cant provide any advice on that side of things, but those are a few things that might be able to help.
hey squall - thanks for the suggestions, what did you mean by projectile? I would have thought particles to be quiet fast… 1 material and 1 quad per particle could render out all bullets in 1 draw call (if you forced an animated frame on each one to be the different bullet/laser images)
Yeh and using sphere colliders would be plenty and they are the fastest as well (simply a radius check)
When I say projectile, sorry I really meant to say “model” or something similar, for example many people MODEL a bullet themselves, I for example am simply using a quad as you said (of course a quad is just 2 triangles but still), My understanding of particles is that in order to CREATE a particle, on the fly, would be more CPU intensive, barely, but I imagine a few % perhaps, though this is just the way I assume it to be, I haven’t ever done any tests or anything to confirm it.
Its just that particles have a timer, for their life, even if its not being used, its stll an extra variable, several settings might not be USED, but the variables for those settings would still be accessed, except they send back the information saying that life = 0 instead of 100 for example, thats a few extra variables running wheras when you have a projectile (in my case just a simple square with an alpha for the bullet), You only use the number of variables that are needed to run, there are no extra settings that need turning off or anything.
This is purely my take on why I feel simple geometry is better then particles, of course, geometry wise its all the same ammount of polygons (1 quad = 2 triangles), but on other levels is where it differs.
I’d be interested in seeing how others might feel about this though.