07/03/16 Update: Debug mode + Gameplay

Over the past couple of weeks I was able to implement these features:

 

Heads Up Display

I made some HUD components to make the game information clearer to see.

HUD_L

Score + multiplier component

HUD_R

Lives component

HUD_vign

Visor component

We were on the fence about keeping the visor component in as it implies that the player is in first person when they are actually playing in third-person, but it had good synergy with the chromatic aberration effect so we decided to keep it in.

First person HUD GUI_scoreGameShot

Chromatic Aberration impact effect

I took the chromatic aberration effect further and made it so the amount of chromatic aberration spikes briefly when the player is hit, then decreases back to the value I previously set, which when used in conjunction with the visor HUD component creates a burst/pulse effect on the edge of the screen similar to a screen shake. This is useful for giving visual feedback on the player’s current status and it gives the illusion of an impact.

hurt gif.gif

(Hard to see blinking hurt animation because of GIF framerate)

Bullet system rework

My previous solution to our shooting problem was to spawn the bullets inside of enemies, causing them to die when clicked. I’ve been able to code a way for bullets to fly directly towards individual enemies allowing for  a cleaner looking shooting system. The major issue that seems to have popped up through feedback is that it gets harder to click directly on the enemies as time progresses due to it being such a specific thing. I think a lock-on mechanic would fix this problem easily, however  we may not have enough time to implement a thorough system.

shooting gif

 

Stage system

I have implemented a stage system that increases the stage in intervals of 8000 points. This is a temporary interval as our score acquisition rate increases with time meaning that jump from stage 1 to stage 2 is much longer than the jump from stage 4 to stage 5. It will take a lot of trial and error and testing to get more accurate numbers or it might even require an alternate stage progression method. The current stage is displayed at the top of the screen.

stage switch gif

Global Speed

There is now a global speed variable that is applied to all moving assets of the game such as enemies and obstacles, making the game feel faster depending on the current stage number.

Enemies increase in frequency as stage progresses

As the stage number increases so does the enemy spawn rate, making it harder as the player progresses. I intend on changing this from simply spawning more of the same enemy to spawning more difficult variations of our enemies or even new ones.

Debug Mode

Pressing escape in-game brings up the debug menu on the top of the screen.

This gives us the following options:

  • F1-F5: Skip to stage
  • F6: Have a bad time (Insta-kill player for testing purposes)
  • F7: God mode (Invincibility state. Turned off when debug menu is closed)

debug mode

High score system

The high score is now shown on the pause/game over menu. This is only stored while the game is open, meaning the value is lost once the game is closed. My next goal in this area is to store the high score to a local file allowing it to remain consistent between game loading. As a stretch goal we could have a leader board system implemented.

 

Life system implementation

I was able to add a life system into the game today. It works by making the player go invisible on enemy collision to imply invincibility frames until the life count has  decremented to the point that the player gets a game over.

Key lines of code:

public int playerLives = 3;

void Start ()
    {
	Debug.Log("Lives:"+playerLives);
        rend = GetComponent();
        rend.enabled = true;
    }

void OnTriggerEnter(Collider col)
	{
		if (col.gameObject.tag == "Enemy" && GodMode == false)
		{   
            if (playerLives <= 1)             {                 Destroy(gameObject);                 PlayerDie.PlayerAlive = false;                 Debug.Log("Death via enemy");             }             if (playerLives >= 2)
            {
                // Health = Health - 100f;
                playerLives--;
                Debug.Log("Player lost a life");
                Debug.Log("Lives:"+playerLives);
                StartCoroutine(blinkTime());
            }

 IEnumerator blinkTime()
    {
        rend.enabled = false;
        yield return new WaitForSeconds(1f);
        rend.enabled = true;
    }

Lives system

I did some research on ways to implement the lives into the HUD and found these examples:

Starfox

Starfox (SNES)

Starfox uses a “Lives x (number of lives)” format which I thought would be quite useful for our game, but decided against it as it implies that the player respawns on the spot which we wanted to avoid. We wanted something that properly showed that the player was getting damaged.

Super street fighter 2

Super Street Fighter 2 – Ryu Portrait

We looked at games that gave feedback of procedural damage to the player and decided that this was a good direction to go in, so I plan to use a similar format for our game. I’ll design a mugshot sprite of the main character with alternative damaged versions.

KHCoM

Kingdom Hearts: Chain of Memories Health HUD

Pause/Death UI, Sound

I was able to script a pause and death user interface menu into the game.

The difference between the pause and death menus is that the death menu does not come up with the option to resume. On both menus the user is able to see the cursor, contrary to the cursor being invisible during gameplay. All music and gameplay is also stopped, this was done by enabling the line of code ‘Time.timescale = 0′.

ss (2015-11-29 at 09.41.16).jpg

I found some royalty-free music on Kevin McCleod’s website that fit in well with the theme of the game. They can serve as placeholder tracks for now but I think they could even work for the final product, depending on our other options. The pitches of the tracks are adjusted in-game to fit better, Unity is slightly slower and Rhinocerous is slightly faster.

Title

Gameplay

I was able to make the music slow down to a stop on death by creating this code:

public float pitchSpeed = 1.19f;
	
	void Update () 
	{
		AudioSource audio = GetComponent();
		
		audio.pitch = pitchSpeed;
	
		if (PlayerDie.PlayerAlive == false)
		{
			pitchSpeed = (pitchSpeed * 0.9f);
				if (audio.pitch <= 0)
				{
				audio.pitch = 0;
				}
		}
		
		if (pauseGame.paused == true)
		{
			audio.pitch = 0;
		}
		
		if (pauseGame.paused == false && PlayerDie.PlayerAlive == true)
		{
		audio.pitch = 1.19f;
		}
	}

This works well because it put emphasis on halting the players momentum. Suddenly stopping the music wouldn’t sound very professional so this is most likely the best way we can accomplish a sudden stop in the audio that is easy on the ears.

Score script

Increase score over time

public class ScoreManager : MonoBehaviour {

	public static float score = 1f;

	public float scorescale = 0.2f;
	public static float scoreMultiplier = 1f;
	public static float enemyPoints = 0f;

	public Text TextScore;


	public GameObject scoreScreen;
	// Use this for initialization
	void Start () 
	{
		score = 0f;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (PlayerDie.PlayerAlive == true)
		{
			score = score+ (scorescale*scoreMultiplier*Time.time); //score growth rate increases over time

	// add code to make score scale reset to 0 every time damage is taken.

			TextScore = scoreScreen.GetComponent();
			TextScore.text = Mathf.Floor(score).ToString();

		}
	}
}

Score increment by 50 with basic enemy killed

void OnTriggerEnter (Collider col)
{
if (col.gameObject.tag == "Bullet")
{
Rigidbody newTrail = Instantiate(explode,transform.position,transform.rotation) as Rigidbody; //instantiate particle explosion animation
newTrail.AddForce(transform.forward*explodeVelocity,ForceMode.VelocityChange);
ScoreManager.score = (ScoreManager.score + 50); // add 50 points to score when enemy is killed
Debug.Log ("enemy dead");
Destroy (gameObject);
}
}

This part of code on the EnemyDie script (Destroys enemies when they come into contact with a bullet) creates a small particle explosion effect and adds a flat value of 50 to the player’s score. In the future I plan to change the flat value to a float variable so I can change score values depending on the type of enemy. I would also like to implement a score multiplier based on enemies destroyed in quick succession.

Capture

UI text displaying updating score value

In the future I would like a way to give visual feedback on how much score the player is getting for  destroying enemies, for example a ‘+50’ could pop up next to the score each time an enemy with the score value of 50 is destroyed.

Pause screen mockup

I wanted to envision what our pause and game over menus would look like so I did some research.

This slideshow requires JavaScript.

I made some quick mockups of the pause and death screens by editing a screenshot of an existing game.

I think pixel style text may be the way to go as it mixes well with our game being blocky and static in a digital world.

It’s important that there isn’t much obscuring the player’s vision on the pause screen because there could always be a threat just behind it. With this in mind I was able to experiment more on the death screen. Since the player is meant to be fighting viruses it makes sense for the game over screen to have some element of corruption within it. Ideas I got here were distorted, glitchy text and a stream of complex data followed by a wait for user input to continue.