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.

Unity bug: Missing (Mono Script)

Due to a unity error that kept popping up when I was backing up my files, my UI scripts disappeared, and I wasn’t able to add them since the only way they can be added is via Add Component > UI, meaning that I need to re-add all components of the code. This is frustrating because I lose any variables that I declared in the inspector.

Bug......

Bug...

Result of the bug. Some UI elements with the same problem disappeared completely, sucha s the reticle.

EDIT: (02/12/15)

I was able to find a fix to this problem by deleting the library folder in the project, then re-opening it so that it reimports all of the assets. Apparently it’s a metadata caused by switching computers.

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.

Lock-on system

Following up on our shooting overhaul, we decided to look into a lock on system that would simplify shooting so we could let the player put a lot more focus into dodging obstacles, an aspect from our previous version that we didn’t want to lose.

I started to delevop a system that automatically fired bullets using pooling (to further reduce lag through the use of recycling). The way this worked is that the bullets would only fire when the mouse is over an enemy.

LO01

Bullets firing towards confirmed target along with lock-on animation

 

reticle_animation_placeholder_by_squirrelkidd-d9j49w1

lock-on animation

I created this lock-on animation in Flash through the use of classic and color tweens. This animation would follow the mouse while locking on and then stay in place once it had locked on. While this is a good step towards visual feedback of locking on I still feel like we need something more impactful to go with this to let the player know that they have locked onto the enemy, I was thinking possibly we could have it so the enemy flashes white for a brief second once they’ve been targeted.

Bullet firingcode:

	void Update ()
	{
//FIRE ON MOUSEOVER
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		RaycastHit hit; 

		if(!Physics.Raycast(ray, out hit))
		{

			canFire = false;
			LockToggle = false;
			CancelInvoke ("Fire");
			return;
		}
		else
		{
			Debug.Log (hit.collider.gameObject);
			canFire = true;
			LockToggle = true;
			SpawnLockOn ();
			lockOnEffect.SetActive(true);
			Invoke("Fire",fireTime);
		}
//FIRE ON CLICK
		if (Physics.Raycast(ray, out hit) && Input.GetMouseButtonDown(0))
			{
//				canFire = true;
				Debug.Log (hit.collider.gameObject);
//				LockToggle = true;
//				SpawnLockOn ();
//				lockOnEffect.SetActive(true);
				Invoke("Fire",fireTime);				
			}
			else	
			{		
//				canFire = false;
			}
//
	}

	void Fire()
	{
		GameObject obj = NewObjectPoolScript.current.GetPooledObject(); //fires bullet

		if (obj == null) return;


		obj.transform.LookAt (EnemyDie.markedObject.transform);
		obj.transform.rotation = transform.rotation;
		obj.SetActive(true); //fires bullet

		firing = true;

	}
	
	void SpawnLockOn()
	{
		if (LockToggle == true && ReLockOk == true)
		{
		Debug.Log ("Spawned lock on");
		LockToggle = false;
		ReLockOk = false;
		}
	}

 

EDIT: 20/11/15

We had to scrap this idea due to a bug – bullets would ricochet between enemies (example: a bullet would fly through an enemy destroying it, then the bullet would change direction after another enemy is clicked). Also sorting out storing the marked enemies and shooting more than one of them was proving to be too time consuming, we didn’t want to have that working and nothing else. I am going to have to change the shooting system a third time and come up with something simple for the time being; I may be able to edit the ‘Fire on click’ section of my code to salvage something though.

 

 

 

 

 

 

 

 

 

 

Downscaling

Since two of our team members have been unable to make it in to work on our game we’ve decided to downscale the scope of the game as we are unable to meet our initially desired outcome.

From now on development of our game is going to continue with a slightly altered vision.

Arcade theme focus

We are aiming to make the game have a very arcade-style influence gameplay wise. This means heavy focus on accumulating score and varied play session length depending on player skill.

Endless runner gameplay

Instead of having multiple levels we will have one endless level that varies in speed and difficulty depending on distance travelled/current score. However we plan to incorporate a stage select that lets you jump to different difficulties if you’ve unlocked them, similar to Tetris. If we are able to get this perfected ahead of schedule we will move onto creating a boss battle sequence as a stretch goal.

 

 

Shooting issue

Initially we wanted to have the shooting fire directly ahead of where the player was, similar to space harrier and the special stage in bayonetta.


Space Harrier


Bayonetta special stage

This posed some problems as the player would have to put themself in a position that did not align with the enemy to successfully shoot it, which didn’t play well as you had to guess a rough area where you needed to be to shoot the target accurately.

The way around this was to switch to orthographic view, but this ruined the look and feel of our game that we wanted to achieve as there was no perspective in the scene.

OT01

Ikarus in ortographic view. Enemy on the left is actually in the distance but there is no way to tell.

Upon finding this out we decided to do an overhaul of the shooting system. We decided to look back at the previous shooting system and make some changes.

Dash mechanic

I was able to code in a dash function that allows the player to quickly move faster in the direction they were already moving in and possibilty gain some invincibility frames. This will help in moments that the player becomes overwhelmed and has no other option. The influence for this came from Super Smash Brothers Melee’s airdodge mechanic, demonstrated below:

Mario_Airdodge_SSBM

Dash mechanic influence

Code:

		if (Input.GetKeyDown ("space") && DashCheck == false && CooldownOn == false) {
			StartCoroutine (Dash ());
			StartCoroutine (CD ());
		} else if (Input.GetKeyUp ("space")) {
			DashCheck = false;
		}
	}
	
		IEnumerator Dash()
		{
				DashOn();
			{
				yield return new WaitForSeconds(DashDuration);
				DashOff ();
				yield return new WaitForSeconds (0.2f);	
				MovSpeed2 ();
				yield return new WaitForSeconds (0.1f);	
				MoveSpeed1Reset ();
		}
		}

		void MovSpeed2()
	{
		xAxisMovSpeed = 2;
		yAxisMovSpeed = 2;
		GetComponent().enabled = false;
	}

		void MoveSpeed1Reset()
	{

		xAxisMovSpeed = 1;
		yAxisMovSpeed = 1;
	}


		void DashOn()
		{
//			Debug.Log ("Dash Mode On");
			DashMode = true;
			DashMoveSpeed = 100f;
			movementSpeed = DashMoveSpeed;
			DashCheck = true;
			xAxisMovSpeed = 3;
			yAxisMovSpeed = 3;
			Vector3 direction = new Vector3 (xAxisMovSpeed, yAxisMovSpeed, 0);
			Vector3 finalDirection = new Vector3 (xAxisMovSpeed , yAxisMovSpeed, 1.0f);
			GetComponent().enabled = false;
			GetComponent().enableEmission = true;
			GetComponent().enabled = true;
	}	

		void DashOff()
		{
			GetComponent().enabled = true;
//			Debug.Log ("Dash Mode Off");
			DashMode = false;
			xAxisMovSpeed = 2;
			yAxisMovSpeed = 2;
			GetComponent().enableEmission = false;
			movementSpeed = DashMoveSpeed * 0.9f * Time.deltaTime;
			if (movementSpeed <= 100f)
			{
				movementSpeed = 100.0f;
			}
		}

	IEnumerator CD() //cooldown on dash
	{
		CooldownOn = true;
//		Debug.Log ("Dash available [ ]");
		yield return new WaitForSeconds (CooldownTime);
		CooldownOn = false;
//		Debug.Log ("Dash available [o]");
	}

I incorporated a cooldown system into this code (IEnumerator CD ()) to stop players from spamming dash to dodge everything.

In the future we may change it so that we have a stamina bar that depletes when you dodge, but I personally feel that at the moment it is too much commitment for just one mechanic, if we have one or two more movement mechanics the energy bar will have a lot more use in terms of balancing.

Glitch effect

We want our glitch effect to be convincing so we did some research on existing glitch effects in media.

Vanellope from Wreck It Ralph has a glitch effect very close to what we would like to go for, though achieving an effect of the same caliber might be too costly regarding the game engine and our time.

A realistic approach would be to use this After Effects plugin Twitch, assuming we are able to get hold of it.

If we use this we could create a stock glitch animation using the twitch plugin and either:

  • Spawn the animation as an animated png sequence and attach it to enemies at the risk of lag.
  • Use the unity particle system to spawn the animation or components of it to give a similar effect.

Level block concept

In the previous version of Ikarus we used texture scrolling on a  plane to create the illusion of movement.

ss_(2015-04-04_at_10.30.11)

Ikarus mk I

We wanted to continue this illusion of movement in this second version of the game but expand upon this to make it a bit more immersive and believeable to fit with our new concept of contrasting visual themes.

We decided to use a ‘level block’ system that spawns a prefab of a level space that move towards the camera at a rate that connects all levels seamlessly. The prefabs are destroyed once they move past the camera to reduce lag.

LVL01

Level block initial placeholder