Before updating to Windows 10 you may need to return your Pro license. More information here

Bullet hell - how to make a lot of bullets?


this is my first post here so bare with me. I am currently attempting to create a 3d bullet hell game. In this game i want to generate a lot of projectiles of varying sorts that are emitted from varying sources. I have tried using instantiate and destroy to create and kill physical (rigidbodied) bullets, but once I get a few sources on screen firing at once, I experience severe slow down. Any thought on how to fix this would be very appreciated!

more ▼

asked Jan 23, 2012 at 04:42 AM

avatar image

26 4 4 7

that's "bear" with me. not "bare".

it's the same word as "bearing a load" or "ball bearing".

Just click "Edit" to fix !

Jan 23, 2012 at 10:40 AM Fattie

Damn spelling nazi! Done :P

Mar 06, 2012 at 09:19 PM Sanosake1
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

You don't really need physics for a bullet hell game - they just travel in a straight line until they smack into something. I think you could save a LOT of processor time by making your own really basic behaviour to keep your bullets moving.

At the moment you'll be calculating all kinds of things you don't need. I'd say 'Keep It Simple'.

So store the Vector3 that is the direction and speed it was shot in, then simply multiply that every frame. So off the top of my head...

   public Vector3 Velocity;
   void Update()
       transform.Translate(Velocity * Time.deltaTime);    

You'll also need to add collision detection of course, but this basic example SHOULD have you with a particle that keeps travelling in the direction it was fired and is MUCH less complex than a RigidBody.

more ▼

answered Jan 23, 2012 at 04:53 AM

avatar image

751 20 18 26

This boosted my fps DRAMATICALLY! THANKS!

Jan 23, 2012 at 06:04 AM Sanosake1
(comments are locked)
10|3000 characters needed characters left

Don't use Instantiate at all if you can avoid it, and certainly not to instantiate bullets in a game of this type. Use an object pool script. There is one ObjectPool.cs, written by Invulse, that you can find on the forum and is free to use as is or modify. It goes in the "Plugins" folder, not "Scripts".

You just need to set the position and rotation of the object in the next line, and make sure you reset whatever needs to be reset on the bullet before calling PoolObject to dispose of it.

more ▼

answered Mar 06, 2012 at 11:00 PM

avatar image

5.2k 198 175 200

Totally agree. I am not sure if this script happens to disable the object, but if you disable them when you add them back in the pool it prevents any unnecessary update calls to those game objects.

Dec 30, 2013 at 08:54 PM Zach3ryH
(comments are locked)
10|3000 characters needed characters left

You could also use particle systems instead of instantiating objects

more ▼

answered Dec 30, 2013 at 09:04 PM

avatar image

82 2 2 7

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jan 23, 2012 at 04:42 AM

Seen: 3055 times

Last Updated: Dec 30, 2013 at 09:04 PM