Dirty Stop Out | Week 2: Dancing, Game Over Screen, Health Notes
Total Time: 4hrs
Thursday 28th March: Session 1: 1pm - 3pm - Random dance poses with every tap
Session 2: 3pm - 3:30pm - Game over screen and Try again functionality
Session 3: 3:30pm - 5pm - Random health notes spawn randomly and heal the player when clicked
Random Dance Poses
I set-up a bunch of dance poses using my character that I'd broken up into different parts (arms, legs etc). I went to Preferences > Grid in PS and set the CM to have a grid line every 10cm. There is an idle pose, a bop dance which is just the first two frames, and the rest is a left and right dab bop thing.
I imported these into Unity and used the splice editor to cut up squares of 10 x 15cm as this is where I had placed my sprites in Photoshop on the grid.
I then added all of the individual sprites into an array of sprites to a Character Manager script along with a sprite renderer which is used to display the sprites.
This is the character manager script:
I added some code to the interaction manager script. Now when the player clicks, the ChangeDancePose() function in the character manager script is triggered.
Game Over Screen & Try Again
I kept getting an error whenever my health ran out, so figured I'd learn how to switch to a game over scene instead.
I saved a copy of the game scene and removed everything apart from the background. Then I added some Game Over text, a retry button and saved the scene as GameOver.scene
It took me some time to figure out how to trigger a script when a button has been clicked. This was because I was trying to drag the script directly onto the OnClick() method of the button. I then found out, you're supposed to add the script to an empty game object first, and then drag the game object with your script attached to the OnClick() method.
For the script, I had to use something called the SceneManagement namespace which contains functions for loading between scenes. I'm not sure if this is necessary, but I also added the scenes to the project settings build files just in case.
This is what the function for loading a scene looked like. I added a string called scene as a parameter so I could just type the name of the scene I wanted to load directly in the OnClick method of the button.
To make the game load the GameOver scene, I added this to my update function of the interaction manager which checks if the health is 0 and loads the GameOver scene if it is.
Random Health Note Spawn
For the random health note spawning, I duplicated the regular music note prefab and created a green version of the image and re-saved the prefab as MusicNoteHealth, adding a MusicNoteHealth tag to the prefab. I added a check in my interaction manager > GetInteraction() function to check if the note had the MusicNoteHealth tag. If it did, then it triggers a Heal(int amount) function on my Health Manager script.
The health function takes an amount parameter which I just insert the musicNoteHealth parameter, modify-able in the inspector. It then adds this to the players current health.
I also had to make sure to add this MusicNoteHealth tag to the penalty box function so that if it collides with the penalty box, it damages the player.
For the random spawning, I added a random value / chance to spawn setting in my interaction manager > SpawnNote() function that is editable in the inspector. This way I can easily control the chance to spawn a health on the fly without having to edit the code.
My game managers now look like this:
Dirty Stop Out
Status | In development |
Author | marshmllow |
Genre | Survival |
Tags | 2D, Comedy, High Score, Minimalist, Real-Time, Touch-Friendly, Unity |
More posts
- Dirty Stop Out | Remake: Part 1, Recycling GameObjectsSep 01, 2019
- Dirty Stop Out | Construct 3: Part 1Jun 10, 2019
- Dirty Stop Out | Week 3: Wierdos, Timer, Health, MusicJun 07, 2019
- Dirty Stop Out | Week 4: Saving & Loading, VFX, DeployingBuildJun 07, 2019
- Dirty Stop Out | Week 1: Framework & DevelopmentJun 07, 2019
- Dirty Stop Out | Week 1: Brainstorming & MockupsJun 07, 2019
Leave a comment
Log in with itch.io to leave a comment.