The structure of the mechs within Unity is pretty important. Each chunk has some degree of communication both with other parts and the world around it, so breaking it all down into manageable pieces is key. This page will serve as a sort of “hub” for each component, and I'll use the wiki format to my advantage in organizing and connection all the pieces.
Part of me thinks I should have one script that handles all player input and redirects it to the various scripts, and another part says that that's what Unity's Input Manager is already doing. I'll have to think about this one a bit longer.
Handles rotation of the cockpit. Current implementation involves the following child-parent tree:
This parenting prevents unwanted rotations by only rotating around one axis per object. I'll add a quick render of the mechanics of it later.
The engine is broken down into a few different parts:
Throttle primarily affects how much force forward is applied to the mech.
The gear is also determined by the throttle. Gear affects the animation (different animations for different gears) and the turn speed. The higher the gear, the harder it is to turn the mech.
Below is an example of how throttle could affect other features of the mech.
|Animation||Slow A||Reg. A||Fast A||Slow B||Reg. B||Fast B||Slow C||Reg. C||Fast C||Reg. D|
|Turn Speed||1 .0||1 .0||1 .0||0.7||0.7||0.7||0.5||0.5||0.5||0.3|
The weapons system and weapons themselves are two different things, with one being an abstraction to the other. The Weapons System handles things like which weapon is active (ready to fire) and triggers the weapon itself. The weapon tells the Weapon System what it's current ammo count is (and when it's out), handles raycasts and instantiates projectiles, and applies damage (with raycast weapons).
The Weapons System also provides weapons with targeting info. Depending on the weapon, it could provide the following:
Weapons can be boiled down to two types, Raycast and Projectile. Raycast checks for instant hits (bullets, laserbeams, railgun ammo), while Projectile instantiates projectiles (missles, blaster fire, grenades).
Raycasts have the following properties:
Projectiles have the following properties: