User Tools

Site Tools


blog:160307_script-and-mech-breakdown

160307 - Script and Mech Breakdown [INCOMPLETE]

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.

Mech

Player Input

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.

Cockpit Control

Handles rotation of the cockpit. Current implementation involves the following child-parent tree:

  • Yaw Empty
    • Pitch Empty
      • Cockpit

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.

Engine

The engine is broken down into a few different parts:

  • Throttle
  • Gear
  • Forward/Reverse
  • Steering

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.

Throttle 0 1 2 3 4 5 6 7 8 9
Gear 1 1 1 2 2 2 3 3 3 4
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

Weapons System

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:

  • The point in space at which the reticule is aiming
  • Target lock (if applicable to the active weapon)

Weapons

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:

  • Range
  • Damage
  • Heat
  • Ray Prefab

Projectiles have the following properties:

  • Projectile Prefab
  • Heat

Jumpjets

Health

UI/HUD

blog/160307_script-and-mech-breakdown.txt · Last modified: 2016/03/10 05:17 by admin