FJ Hagen

Right now, my enemies just go straight down on the screen. To spruce this up, I should have them move diagonally. Here’s some code for that:

The enemy moves to the left when they start on the right side of the screen and to the right when they’re on the left side of the screen. When they reach the bottom of the screen and respawn at the top, their starting point changes accordingly. Here’s the change in action:

--

--

It would be cool to have the camera shake when the player takes damage. Thankfully, Unity provides a way to do that via code. Here’s a script that provides a camera shake. I’ll attach it to my Main Camera.

I’ll call the Shake method in my Player script in…

--

--

Right now, if I launch a PC build and play in full screen, there’s no way to exit my game except to go into the Task Manager and close it out there. No one wants to do that, so I need another way to close out my game. The escape key is always an option. Making the escape key close out the game is as simple as adding this code to our project in Update, preferably in the same place where you restart the project after the game is over.

Keep in mind that this will not work in the editor. You’ll need to make a build to see the effect. The next episode will be a surprise. Stay tuned.

--

--