You are on page 1of 6

Hyun Jae Moon, Park ESM 2015

GoodLuck
<Test Game, Concept and Techniques>
1. Game Concept
1) This game is divided into two modes: Easy and Hard.
2) In Easy mode, after every stage, the enemy plane increases by one. In Hard mode, by 3.
3) The speed of the enemy plane in Hard mode increases twice faster than that of enemy
plane in Easy mode.
4) The main plane increases its speed every stage.
5) Left click shoots regular missiles. Right click shoots target missiles. Target missiles do
have a slight delay every click.
6) After a crash with an enemy plane, the camera vibrates and the health is reduced.
7) Every enemy plane destroyed gives 1 point.
8) After traveling a certain distance, it moves on to the next stage.
2. Techniques
1) After subtracting the enemy's position from a main plane's position, I've normalized
the vector and made the enemy plane move towards the main plane.

How to calculate direction


Vector3 myPos;
Vector3 enumyPos;

// Main plane's position


// Enemy plane's position

Vector3 direction = myPos - enumyPos;

//

The

direction

from

enemy's

position to main plane's position. (Used the direction value)


direction = Vector3.Normalize(direction);
with the direction value calculated.

// One must use the normalized vector value

2) In the case of target missile, the initial vector of the target missile would be fired up,
down, left, right, and 4 diagonals. Each target missile will randomly select one and
calculate the direction like we did in 1). Then the target missile will accurately
accelerate towards the enemy plane by shifting the transfomr.foward towards the
enemy plane's position.

The Shooting of the Target Missile


Vector3 vEnumyPos;

// As target missile is launched, the selected enemy's position

Vector3 vMyPos;

// Target Missile's position

Vector3 vRevision;

// A vector that will revise the direction of the target missile.

Vector3 vForward;

// A vector that will transform the target missile forward.

Vector3 vDirection;

// The direction of the enemy plane from the perspective of

the target missile


float

fAccel;

// The acceleration of the Target Missile

// The initial directional vector of the target missile must aim up, down, right, left, 4
diagonals like the following:
vRevision.x = 0.0f;

vRevision.x = 100.0f;

vRevision.y = 100.0f;

vRevision.y = 100.0f;

vRevision.z = 100.0f;

vRevision.z = 100.0f;

// Subtracting the enemy's position by the target missile's position will show the direction
that the target missile will point.
vDirection = vEnumyPos - vMyPos;

// Normalize the direction of the target missile with the revising vector to transform the

direction of the target missile towards forward.


vForward = Vector3.Normalize( vRevision + vDirection );

// Using the vDirection, add fAccel to add acceleration.


// fAccel will be constantly added by 1f every frame using the Update () function.
vMyPos.position += vForward * fAccel;

// vForward must be justified as transform.forward to make sure that the target missile
will point towards the enemy plane.
transform.forward = vForward;

// If the x, y, z component of the vRevision value is greater or smaller than zero, certain
value will be constantly added or subtracted to make it zero.
// As the vRevision value decreases to zero, the fForward will eventually point towards
only with the vDirection value.
if( vShot.x > 0.0f ) vShot.x -= 2.0f; // making the x, y, z component zero.
if( vShot.x < 0.0f ) vShot.x += 2.0f;

3) The Motion of the Camera


On the Hierarchy section, locate and fix the camera's position on the main plane.

Tilting the Camera


Vector3

euler;

// Vector to measure the euler angle

Quaternion

quaternion

// The quaternion angle that will be added to the main plane's

transform.rotation.
Transform

myTM

// the trasnform of the main plane.

bool

isSideMove

// Checking if the main plane is moving sideways.

bool

isCollision

// Checking if the main plane has collided.

float

fCollisionAngle

// The change in angle on the z-axis as the main plane collides.

float

fCollisionTime

// The time of the camera shaking after the collision.

float

fTime

// Time.deltaTime cumulating the time value.

// If the eulers.z value is smaller or bigger than a certain value, addition and subtraction will occur
to rotate the main plane on the z-axis as it moves sideways.
// Rotating the plane will rotate the camera as well.
if( isSideMove == true ) {
if( vEuler.z <= 20.0f ) euler.z += 1.0f;
quaternion.eulerAngle = euler;
myTM.rotation = quaternion;
}

// isSideMvoe is false, rotate the main plane's z axis back to zero.


if( isSideMove == false ) {

if( euler.z > 0.0f ) {


euler.z -= 1.0f;
quaternion.eulerAngles = euler;
transform.rotation = quaternion;
}
}

// Collision will make isCollision true, the Camera will vibrate for fCollisionTime. Just like the
method written above, shake the main plane on the z-axis.
if( isCollision == true ) {
if( fTime > fCollisionTime ) {
// If fTime value becomes greater than fCollision Time, make isCollision false and
make fTime=0f.
isCollision = false;
fTime = 0f;
}

// Constantly increase fTime value by Time.deltaTime. If fTime=1f, then 1 second.


// fCollisionTime = nf => n seconds
fTime += Time.deltaTime;

// fCollisionAngle value increases at a faster rate by multiplying 50f on Time.deltaTime


value.
// fCollisionAngle goes in to Mathf.Sin function and make the vibration even faster

between -1~1.
fCollisionAngle += Time.deltaTime * 50f;
// If float value is added in Mathf.Sin, it will constantly go back and forth between -1 and
1. Just like a Sin function.
// If Mathf.Sin value is cumulating in the euler.z, -z~+z range will be established. This
value will be added in to the main plane's transform.rotation.
euler.z += Mathf.Sin(fCollisionAngle);
quaternion = euler;
myTm.rotation = quaternion;
}

You might also like