Dirty Stop Out | Week 1: ​Framework & Development


Time Spent Total: 8 hours

Sunday 24th: Session 1: 2 hours
                               Session 2: 2 hours
Monday 25th: 2 hours
Wednesday 27th: 2 hours
 

Placeholder Art

Since Sunday, I have been focusing on laying down the framework for the game and getting some rough placeholder art in. I've heard that it's probably better to use basic shapes rather than art from the get-go, but I decided I wanted more refined art to help me visualise stuff better. I also needed a character so that I can create the initial dance poses. 

Code Framework

There are probably better ways to organise code for a project, but I lack the experience to really know. So I decided, I'm going to just start, and not worry too much about how messy everything is. Then I can learn from whatever I did. 

I knew which mechanics I wanted for my game, so I figured I'd have a script that handled each one individually, and I also wanted scripts that could communicate and effect each other;

Scripts
* Health bar / life system
* Musical Notes
* Weirdos
* Request a song, DJ ability
* + Interaction Manager (added this since last time)

I also wanted an overall script to handle all of the Interactions, and that I could use to modify any of the dynamics so these could easily be changed (eg. amount of damage you receive when you're hit by a weirdo).

Scene Setup

I did all the basic stuff, like adding a background, putting in a UI canvas and creating / importing sprites.

 Interaction Manager

I have one script called the interaction manager to handle all interaction variables that can be changed by me in the inspector (example: damage received when hit by a weirdo).

The interaction manager currently handles spawning of the musical note prefabs, animations and spawn locations.

 I tried to have a separate Music manager for these but thought it was best to have them all in the same script as it was getting too complicated.

 I've added the script below so you can see how this was set-up. The interaction manager works using Unity's tagging system. This means that whenever a player clicks on an object, a raycast line is sent from the mouse to whatever was clicked. The raycast stores information from the object and is able to check what tag is applied to it. 

 In this case, if the tag is MusicNote, then a function will trigger which causes the note to be destroyed (or to disappear when clicked). 

 

Health Manager

The only thing I was able to handle in a separate script was the health manager. This contains all of the images for each health bar and updates the current and starting health.

 

Penalty Box

For the penalty box, this was originally handled by the interaction manager, but I moved it to it's own script and applied that directly to the penalty box itself.

 It took me a while to get this to work properly. I wanted it so that whenever a musical note collided with the penalty box, it would deplete the players health by a number of points. To do this, I set the penalty box's Box Collider as an 'IsTrigger'. This means that things can pass through it. Originally, I didn't realise this and notes would just bump into the penalty box's surface and become stuck.

Next, the note prefab had to contain a rigid body to work. 

 

In the penalty box script, I created a reference to the health manager so that I could affect the current health directly depending on whether a not a note entered the penalty box collision. 

 

Schedule

Now that my project was getting somewhere I decided to have a rough schedule of everything I needed to do before the 4 week deadline as well as begin to list all of the bugs that are beginning to crop up.

According to my schedule, I need to deplay the game to an iphone or ipad for testing, implement dancing animations when the notes are tapped and also add the randomly generated health note that heals the player when clicked.

 

 

Problems & Solutions

1. Destroying a prefab that contains a coroutine

Description: I had a problem where I was spawning prefabs and then applying a coroutine to them to make them move upwards. When I clicked the object to destroy it, I was getting a null exception error. 

Resolution: The reason this was happening was because I didn't have any reference to newly spawned prefabs. To fix this, I had to add each new prefab and their coroutine to a dictionary. This way, I can tell the program to remove the clicked prefab in the dictionary and to remove it's coroutine. I also have a check to ensure that there is a coroutine in motion, if there isn't then the prefab is just removed.

2. Unable to click on UI image to trigger script

Description: For a while I was trying to figure out how to detect a click on an image in order for it to be destroyed when clicked.

Solution: Images can't be clicked if they have no collider. I had to put a box collider on to the music note prefab and store the clicked collision in order for it to be destroyed when clicked.

Leave a comment

Log in with itch.io to leave a comment.