Post navigation

Spreadshot and Weapons Systems

After discussing the issue with my friend on the terminology, I think I’m going to abstract all the “powerups” into “systems”. That way, I don’t have to worry about what to call a system (shield as defense, gun as weapon, etc… they’re all just generic systems that have an activate method).

As for one of the hurdles I mentioned in my last post (spreadshot requiring 3 objects, which complicates things), I noticed that there is a “physics.ignorecollision” feature. I also remembered (via the documentation for ignorecollision) that there is a collision matrix, so I can have all the bullets on their own layer and choose so that bullets don’t collide with things on that layer (i.e. other bullets).

This saves me the hassle of having 3 separate gun objects spread apart so as not to touch bullets upon firing. Now I can have 1 single gun object, and when spreadfire is active, just change the activate script to spawn 3 bullets, each one rotated by a specific amount (probably +/- 30) via code as opposed to rotating the prefabs on the ship. Since I don’t have to worry about collision, they can all spawn from the same point. Not sure I fully like that, I kinda like the idea of bullets coming from three separate guns on the ship (nose gun and two wing cannons). But if that’s what I need to do to make it easier to program the weapons system, I might do it that way.

On the other hand, if I figure out a way to implement sub-systems (like 3 guns in one system object), it might come in handy in the future in unforeseen ways. There may be another system I think of that might be able to utilize that, whereas if I limit myself with a specific architecture like 1 object per system, I can’t expand on that or will have to code the extra objects per system at a future time (or skip it all together).

Frankly, just to get this thing to ship and knowing it’s my first game, I don’t think I’m going to worry too much about expandability. I don’t particularly expect this thing to make much, if any, money, and I have other ideas I want to program after this, so I don’t plan on doing a lot of program changes besides bug fixes after it’s finished. Unless for some strange mad reason, it actually takes off.