Corey Strobbe's profile

Prototype - Alien Chase

Project: Alien Chase - Basic Personal Game Prototype
Development on this prototype has ended.  You can play the latest game build at the itch.io page
Initial Design Document​​​​​​​
This design document was downloaded as part of the Junior Programmer Unity course and filled out with this prototype project.  In it are the basic elements of the game, the planned milestones, and images laying out the basic visual information on what the game will look like.
Milestone 1 - Results
Build Showing Results of Milestone 1 Completion
Milestone 1: The Takeaways
The biggest takeaway from Milestone one is that I overestimated the amount of time it would take me to complete the tasks I had laid out for this milestone.  I was able to complete most of it in one day's time.  I think that in future milestones, I will need to spend more time on each task to get more in depth on them and try to make something a little bit more complete or polished.  Either that, or I can plan to do more tasks in that time so that later milestones can be edited to plan for deeper tasks.
Milestone 2
The Goals
- Get a functioning Main Menu with functional buttons to Start the game and quit the game
- Have the police cars spawn in a random spawn point at regular intervals
- Have the police cars destroy the player upon collision
The Results and Retrospectives
- Get a functioning Main Menu with functional buttons to Start the game and quit the game

I had some trouble remembering how to make functional UI buttons in Unity but this was nothing that a little bit of research helped to clear up.  The result is a fully functioning main menu that behaves as expected.

Have the police cars spawn in a random spawn point at regular intervals

As shown in the video below, the police cars spawn from the 3 spawn points set up at the end of the playing field.  The code picks one of those 3 points at random and Instantiate()'s a police prefab at an interval that I'm currently able to adjust in a public variable in the editor.  I may end up initializing those variables later unless I decide to add more levels down the road and adjust those variables level to level.  At point of Milestone 2, that hasn't been decided yet.

Have the police cars destroy the player upon collision

This goal was pretty easy.  All I did was have the Player destroyed upon colliding with the police car's BoxCollider.  This did lead to a cascading error in the console complaining about a missing Player reference on the Follow camera, but I was able to clear that up by having the camera's follow code check for if player != null.  I can also use this later to make the Game Over screen in a later Milestone.
The Video
Build showing the results of Milestone 2
Concluding Thoughts

Milestone 2 went very smoothly overall.  Some frustration arose from not remembering how to program certain methods but was able to overcome that by doing a bit of research.

As with Milestone 1, I overestimated the amount of time it would take me to accomplish these tasks, which isn't a bad problem to have.  But it does mean that, because I have no dependents other than myself and my own time and have the luxury of going at my own pace, I've wrapped Milestone 2 early and can start Milestone 3 early as well.

What I also can do at this point is try to add tasks from the backlog into future milestones to fill up the task list to fit the schedule that I planned out.
Milestone 3
The Goals
- Get the player to be able to shoot projectiles
- Have the projectiles destroy the police cars
- Give the player incremental health that decreases upon collision with the police cars.
The Results and Retrospectives
- Get the player to be able to shoot projectiles

Projectiles gave me a little bit of trouble at first.  Originally I had the projectile instantiate itself from a spawn point in front of the player.  However, the way I had it coded instantiated the projectile as a child of the player, as I wrote the code into the player script.  As a result, when every the player moved, the projectile would move with the player.

A bit of research into this problem lead to instead making a different script that would be attached to the spawn point itself rather than on the player.  This fixed this problem and as you can see in the video, the projectile acts as designed.

I did notice a small bug with this while recording the video for this build, which is that while standing still and shooting, the projectile forces the player to shift backward slightly, so I will fix that in the next update.  It should be a simple fix.

- Have the projectiles destroy the police cars

Once the projectile was working the way I intended, having it destroy the police cars was very easy.  I just copied the same code from police destroying the player and applied it to the projectile and police cars.

One thing I did have to do differently for the projectile though is while it destroyed the police car, it kept going and then would destroy all subsequent cars in that row.  So I had the projectile destroy itself as well.

- Give the player incremental health that decreases upon collision with the police cars.

This was also fairly simple thankfully, though it took a little bit of tinkering to remember how to do this.

The first thing I did here was add a health variable to the PlayerController and had the PoliceController call that number from the PlayerController script.  So now it's an if/else statement that checks the player health number.  

If health == higher than 1, health -1 and destroy self.  Else, health -1 && destroy both.
Concluding Thoughts​​​​​​​
It's pretty clear at this point to me that my milestone schedule is very sparse for how quickly these tasks are taking me.  At this point in this project, I've decided to scratch the schedule and just update this with milestone results as they get done, which has so far only taken a couple of days to do.

For future projects, I'm going to plan more work for each milestone to try to balance the schedule with the tasks so that the amount of work better fits each milestone deadline.
Milestone 4
The Goals

- Add functional Score UI
- Allow user to reset game
- Audio for Projectile and Destroying Enemies
- Add functional Score UI

Once I had the actual score counting functionality working, plugging it into a UI element didn't take very long.  In the current build, it isn't pretty but that wasn't the goal.  I just wanted it to count the scores in a text element, which is present in this build.  Doctoring it up will come later.

- Allow user to reset game

As it stands, the player is able to do this at any point.  This is to show that this functions and that the player is able to restart easily in the absence of a Game Over screen.  A play loop is now present for players to play!

- Audio for Projectile and Destroying Enemies

I used some free assets from the Unity marketplace to get audio clips to use for shooting the projectile and the projectile hitting an enemy.  It's very basic and could probably use some touching up and in-engine mixing but for now, the audio is present and playing as designed.
Video of Milestone 4 results
Milestone 5
The Goals

- Add Health UI
- Fix UI Anchoring
- Implement a Game Over screen
- General Polish with Game Scene
The Results and Retrospectives
- Add Health UI

As shown in the video below, I now have functional UI for health.  This took a little bit of thinking but I found a tutorial for a pretty easy way to make an Image[] to hold the Images and then had them disappear in a way that reflects the player's health integer variable.

Once I had that functioning, I changed the code following a tutorial to then do that same thing, but instead of making the heart images disappear, it uses a bool variable to swap each image from a Full Heart to an Empty Heart.  

The way I implemented this was for some scalability.  Later in development, I plan to add some powerups that may increase health and since this functionality is an Image Array, adding hearts is as simple as duplicating them on the Canvas and adding them to the Array without breaking anything.

I made both of those images into sprite making them from basic shapes in Pixlr Express.

- Fix UI Anchoring

I spent a decent chunk of time this milestone researching basic Anchoring tips because it was clear when I was messing with the anchors that I didn't know what I was doing.  A few tutorials and educated experimentation got me to have a little better understanding of how UI Anchoring works.  At least enough to make basic adjustments.

I spend some time fixing some weird anchoring issues in the game and made sure to test them with different window sizes and resolution settings and as far as I can tell, it looks good now.

- Implement a Game Over screen

I questioned a few different ways to do this.  The first way was to use the same Canvas as the gameplay UI elements and just have the Game Over elements hidden during gameplay and unhidden after the player dies.  This proved to be a little confusing so I opted to do it a different way.

That different way was a separate Canvas that held the Game Over text and the available buttons.

The result is a boolean that already existed to check if the player was alive or dead being utilized to set the respective Canvas as active.  You can see the resulting code in the images below (Image 1-3)

- General Polish with Game Scene

I didn't really need to do this part for this milestone, but I had some time before the due date so decided to anyway.

The first thing I did was set Projectile to be destroyed after a certain amount of time to avoid a potential memory leak from too many particles.  I was unable to figure out a way to destroy the projectile based on an amount of time, so instead I just put a DeathWall object behind the spawners as a temporary fix.

After that I added barriers to the road to prevent the player from falling off the side.  This was something I should've done earlier but focused more on actually gameplay functionality.  But now that should prevent the player from falling.

Video showing results of Milestone 5
Milestone 5 - Image 1
Milestone 5 - Image 2
Milestone 5 - Image 3
Concluding Thoughts

I'm pretty happy with the end result of Milestone 5.  At this point I think I have a Minimum Viable Product for this prototype.  There's a few things I want to polish up and build on to make it a little more fun and challenging to work toward something more akin to an Alpha build.  

I'm going to call Milestone 6 the end of the Prototype phase for the basic gameplay elements and from that point will be building out into a more complex game building off the systems in this prototype.  Milestone 6 will be the MVP for this project and I will be calling that a finished Prototype.
Milestone 6
The Goals

- Add incremental player health
- Heal the player
- Save and display a high score
- Incremental difficulty
The Results and Retrospectives
- Incremental difficulty

The first major goal of the milestone was to make the game get more difficult as it went on.  At first I wasn't sure how I wanted to do this.  I knew that I wanted enemies to get faster based on a score threshold, as well as spawn more frequently.

Unfortunately I was not very prudent in setting up the initial spawning system for enemies and because of the way InvokeRepeating() works -- that being it will run the a function and call it repeatedly, but the same way each time -- I had to find a small work around.

That work around ended up being a bit tricky but ultimately not very complicated.  I made a function that would CancelInvoke(), which cancels any Invoke() function currently running, increment the frequency of the spawning as well as the police prefab's speed, then InvokeRepeating() again with the incremented variables.  And then to make sure the initial police speed reset back to it's initial number, I had a function that sets it back to that number and calling it whenever the game mode is reset.

The end result is that as the player racks up points, police frequency and speed increases after each point threshold!

- Heal the player + Incremental Hearts

With that incremental difficulty, I think it was only fair to give players a fighting chance.  This one gave me a lot of headaches but I was able to get it working in the end.

When I initially made the heart container system, I used a tutorial that made it very easy to add more hearts in runtime.  All I had to do was take the code that was already there and tweak it to add more health in runtime based on a point threshold and do the same for the Hearts[] image array.  It took some fiddling with to get it to work properly but I managed to get it in the end.

I also had it heal the player based on a point threshold, which was as simple as if (player health < max health) {health++}.

- Save and display a high score

This is probably the task that I'm most proud of getting to work, mostly because it also gave me the most headaches.

I was less than prudent when I initially set up a Game Manager and the menu system.  I didn't think ahead about having to navigate between scenes very often and the Game Manager was not handling being carried from scene to scene very well without breaking menus, so storing a player score and a high score from the game to the Main Menu wasn't going to work how I thought it would with the manager.

I did however manage to find a relatively easy workaround after messing with a number of ideas.  That solution was making a dedicated Score Keeper GameObject that would update a High Score variable based on the player's Final Score.  If the player's Final Score > High Score, High Score = Final Score.

That ScoreKeeper then holds that high score no matter what scene the player is in.  So when it goes to the main menu, it looks for a HighScoreText Text object and sends the High Score variable toString on that text variable.  And Voila!  The player has a high score!
Concluding Thoughts

Milestone 6 was some of the hardest work of coding I've done in a long time.  But it was also one that I think really tested my ability to stick things out, research, and experiment.  And ultimately, it paid off, even if the final product has some duct tape in places if you will.

Milestone 6 was also my final goal for getting the Minimum Viable Product for this prototype.  While I didn't do some of the stuff I wanted to do by now like make some primitive models for the player or police cars, I know now to plan that stuff into the milestones in future portfolio projects as well as pack those milestones with a little bit more work.  I know I can handle it after this project.

This marks the end of this portfolio piece.  Go play the game here!
Development on this prototype has ended.  You can play the latest game build at the itch.io page
Prototype - Alien Chase
Published:

Owner

Prototype - Alien Chase

Published: