[WIP] Space Ship Wrapper Ideas And Help

ok so i am in the process of making a spaceship wrapper.
it currently has a full range of control.
but heres my problems and things to do:

  1. build shield system
  2. build weapons system(a forward shooting projectile system and a target seeking system and a 360 degree turret system as well)
    3.build energy management system
    and 4.(this is the important one) setup all of the above and the engine system to work on multiple ship at once in the same scene
    so first i would like some help with prob number 4, i thing the answer lies in something to do with classes but i am no good with classes
    some help with that would be very much appreciated
    and i would like some suggestions on ideas to build the shields, energy management and weapons systems
    example blend file attached
    all your ideas and help are very much appreciated and thanks in advance


SpaceShipWrapper.blend (91.1 KB)

Well, classes can make things easier, but they are hard to get your head around at first.

My current space-ship wrapper (yes, I have one, no, it isn’t suitable for your type of space-ship) has the following:

  • A ‘ship’ class, handles animations, energy, colors, applying forces etc. Also has a ‘controlled_by’ attribute, which can be set to:
    ----- A player function, returns the players input as an intended direction for the ship to travel it.
    ----- An AI function, which returns an AI’s input as an intended direction for the ship
    ----- Or set to none, so the ship doesn’t move

So, the ‘ship’ class is made up of various parts, it has things like:

  • An energy bank
  • A shield bank
  • A weapons system

The advantage of this is that things are modular. The part that handles player code doesn’t know about the ships energy, all it does is tell the ship what the player wants to do, the ship does it if it can. If the player leaves the ship, you can simply set the controlled_by attribute to none, so that no-one is controlling it, or you can set it to AI, and let an AI take control.
The AI function itself is actually a little more than a function, as no AI’s are the same, it goes and creates an instance of an AI class, which has access to things like the ships energy, allowing it to make more informed decisions. Because each AI is an instance of a class, each AI can be slightly different, allowing a little more variation in player interaction.