I am currently making a shooter in Bevy. And I'd like to create a weapon system, the player could have any number of weapons but only select one weapon at a time. You can shoot a weapon with the left click. I'd like to make the function that actually fires the weapon to be a system (which improves parallelism and makes getting resources and components easier)
#Designing a weapon system
4 messages · Page 1 of 1 (latest)
I also want to support passive weapons (Weapons that do something without being selected, or even weapons that cannot be selected at all)
Ok so I think I got something that I like:
- Every weapon is a component on the player
- Theres a
SelectedWeaponcomponent that stores theTypeIdof the selected weapon - Most weapons have a system that checks if its the selected weapon and the fire button is pressed
- If all conditions are passed, fire the weapon
I think you could definitely prototype with just systems, but I would encourage you to look at events: https://bevy-cheatbook.github.io/programming/events.html
Then you can have a system, for example, that listens for a custom FireButtonPressed event that also queries for the component with SelectedWeapon.