Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

If you count unity's instantiate function as a bullet spawning method then yes (hopefully the performance isn't brutalized too hard lol)

Basically yeah lol! Im gunna try doing it with pooling and instantiating stuff  through that and go from there. If its too slow then im just going to try to find optimisations i can do and hope.

Thats if someone else doesnt come on here and gives out a good easy alternative at least

(2 edits)

so there are a few levels of performance, it depends on your target hardware and how many bullets you want to spawn!

The worst is using Instantiate, where every bullet has a script and a rigidbody.

The easiest optimisation is to ditch Instantiate and use a pooling system - I highly recommend LeanPool, it's so easy to use!

For another performance boost, get rid of the monobehaviour on every bullet, and have one Bullet Manager class that moves all the bullets. 

Then, remove the rigidbody and collider on the bullet, and use Physics2D.OverlapCircle (or OverlapCapsule if you want continuous collision detection lite 😂) in the bullet manager in fixed update.

Then swap out OverlapCircle for OverlapCircleNonAlloc.

Then ditch the Gameobjects entirely, and use Graphics.DrawMesh to render your bullets.

Then ditch unity physics and write your own using jobs and burst. This is where my asset stops - it'll do 10,000 bullets on screen at a solid 60fps on my MacBook!

Then ditch all of that and do it all in a compute shader 😂

Remember to always filter your collisions! One of the best ways to optimise is to just do fewer things - bullets *do not* need to collide with each other, you can use Unity's layers and collision matric for that. Oh and circle/sphere colliders are computationally the cheapest. Use them wherever possible 😁

omg that’s so much help! Thank you so much! I’ll do all of those things then and give it my best try! Thanks for the help and sorry for not buying your asset 😬 (I’m a broke bi*** 🤣)

it is free during the jam! Only restriction is that it will stop your project from building once the jam has finished ☺️

You don't need to do all of them. The last three are hugely overkill - that's for console games or maybe low end android phones 😂 you'll probably do fine just pooling them and using a bullet manager instead of a bullet script on every bullet!

Yeah i saw that, the stopping the project building after is the thing that stopped me from using it as i didnt want to leanr how to use BulletFury then have to replace it all and learn pooling too to get it to work after. Just easier for me to dive into the deep end instead :) 

Yeah ill probably stick to the pooling, the manager and the collisions being reduced and see how that goes :) 

Just a few more questions now that ive started adding these adaptions to my project.

  • With the bullet manager is that still using monobehaviour? Isnt fixedUpdate a monobehaviour method?
  • Is LeanPool a unity based pool or is it an asset that i need to get?

yep so the bullet manager is just *one* script on the object that's doing the shooting. Having a bullet script on every bullet is the thing we're trying to avoid with this ☺️

LeanPool is an asset from the asset store, it's free! You just replace Instantiate with LeanPool.Spawn, everything else is the same. Almost makes you wonder why unity doesn't have something this simple - unity itself has pooling built in, but it's way more complicated! https://assetstore.unity.com/packages/tools/utilities/lean-pool-35666