Starfighter

Models and Dogfighting AI

Overview

Development: 2 Weeks (Solo Project)
Finished: May 2011
Genre: Space Sim
Platforms: PC, WebPlayer

This is my first 3D game, a 3rd person space shooter. It is designed to showcase Newtonian flight physics and basic AI for targeting and dogfighting. I also created and textured all of the models in the game. You can try the demo by clicking on the webplayer button below.

Demo Try it out!

← Click here to launch the webplayer and try the game!

Details How does it work?

Your ship uses true Newtonian physics to fly. As you move the camera, the ship turns to look in that direction then applies force from the thrusters until it meets the target velocity. The ship also experiences a "drag"-force to make it easier to fly. This drag could be interpreted as atmospheric drag or corrective thrusters. Drag is simply an additional force acting on the ship that is proportional and opposed to your current velocity.

The mines and drones use a prediction algorithm to make accurate shots. They do this by solving the quadratic for the equation of motion to find out where the target will be when the projectile can hit it, x',


x'   =   (Vector) Relative Position at Impact
x   =   (Vector) Current Relative Position
v   =   (Vector) Relative Velocity
t   =   Time Until Impact
s   =   Projectile Speed


This equation only solves for a target and attacker moving at constant velocities with respect to each other. If the target is accelerating or rapidly changing direction when the shot is fired, it will probably miss.

The drones use a pack fighting tactic to engage you:

- First they ignore you and wait until you're busy with the mines (they start hidden, hanging from the underside of the outpost)

- If a drone detects that the player is spending a lot of time looking in its direction it will break away and try to evade.

- When this happens the other drones fly behind the player, match speeds and begin firing as the player chases their comrade.


This is implemented using a simple state machine with timers and subroutines to check where the player is and what they are looking at. Drones have the following states:

- Sleep   The drones wait until they are fired at or until 5 mines have been destroyed.
- Drop   They detach from the outpost and drop in freefall for 5 seconds.
- Attack   They move towards the player then try to move behind them.
- Fade   The drone moves away from the player before starting a new attack run.
- Scramble   The drone realises the player is looking at them and evades.
- Stunned   The drone spins out of control after a mid-air collision.