Arcade shooter handle multiple attacks and multiple player ships

I’m currently working on a arcade space shooter, in this game the player can choose different ships, every ship has different properties, some can be faster, some others can have more health, they all have different sprites sizes.

There’s a couple of attacks, single laser, double and triple, so for every ship there needs to be a configuration for each attack, as of now I structured my ship prefab like this

6383937--711453--upload_2020-10-5_14-31-47.png

The parent has the collider, rigidbody and player script (which is an extension of the Ship script with the touch controls), the children are the configurations and the children of the configurations are the muzzles, which are the points from which the bullets should spawn.

The ship prefab can’t shoot, the different configs have a script that makes them shoot using the specified muzzles, this anyway is a little hard and messy to handle, whenever I pick up a powerup that powerup has a name with the config and inside the powerup script I have access to the Ship script so I disable all configs attacks and then enable the one hold by the powerup, when the powerup expires I simply disable all configs attacks and re-enable the Default one.

I was wondering if there’s a better way of doing this since the various config have 2 scripts: the one with the attack and the one that lets me get the muzzles, I can’t merge the two for reasons.

I already tried using ScriptableObjects but I ended up throwing them away because they didn’t really fit,any tips?

I am not understanding why you cannot get the muzzles (attack spawn points) in your attack script. Either make them public and drag those muzzle gameobjects in or make them private and use [SerializeField].

@Cornysam

The script for the attack is the same for the ship so if that script attached to the config will fetch for the muzzle it will also fetch the muzzles from the parent ship

The scripts have the following hierarchy

Entity (used for the config, has the attack parameters) => Ship => Player,Enemy

For this reason I create a ShipConfig script that simply fetches the muzzles, but I guess you’re right I could make them public and drag/drop them inside the Ship. The part about disabling/enabling attacks is still a little messy thought and I was wondering if there’s a better way of doing it

Im sure there is, but i dont know exactly what it is. Here is a tutorial on Object Pooling I have seen but he demonstrates different attacks on a space ship type game. You should be able to reconfig his script to make it work for you