Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Anyone using their own bullet spawning system?

A topic by burdy96 created Apr 28, 2023 Views: 445 Replies: 10
Viewing posts 1 to 4

I was just wondering whether anyone is using their own system for the bullet spawning other then the one given? I was thinking of making my own as i want to keep adding to the game after and not have the game not work becasue I dont have the paid version of BulletFury. 

Basically just wanted to see if people were going to do their own and if they have any good links on how to make optimised bullet spawning from scratch :) 

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

Jam Host (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鈥檚 so much help! Thank you so much! I鈥檒l do all of those things then and give it my best try! Thanks for the help and sorry for not buying your asset 馃槵 (I鈥檓 a broke bi*** 馃ぃ)

Jam Host

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?
Jam Host

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

Submitted

Yes, i am using my own spawn system to spawn the bullets

Submitted

Same, homebrew system here but Im' going 3D so I had to come up with my own system.