Making an infinite runner: Part 7

Jun 11, 2019 at 10:00 am by nemirc

You now have a fully functional game, but there are a few things you could do. In this article, I would like to share a few ideas that can make your game more interesting.

Spawning particles when a coin is collected.

One thing you could do is create some particle effects every time a coin is collected, and this would greatly add the visual aspect of your game since it will add an extra layer of interaction between the objects.

To do this, basically what you need to do is get the position of the coin at the moment it's collected, and then create a particle effect at that position. Another thing you can do is make the game play a sound when the coin is collected, adding to the overall "game feel."

Camera shake.

Depending on the kind of game, you can add a subtle camera shake to your camera, to sell the idea of high speed. To do this, first you need to re-arrange your camera a little bit. And make it the child of a root object. Here's the important thing. Originally, your camera had the "Smooth Follow Action" state machine, but now you are going to remove that state machine from your camera and add it to your root object (CamBase in my case). Then, below that add an empty object, and then put your camera below that second empty object (see image). Add an FSM component to the second empty object and add this state machine. Keep in mind that iTween is not included in PlayMaker, so you have to download it from the Ecosystem browser (check the PlayMaker documentation for more information about that).

Lastly, if you want to add a short camera shake to your camera every time you hit an obstacle, you can use a separate state machine to do that. The reason I'd advice you to use a separate state machine is because it will prevent the constant screen shake to get into conflict with your abrupt camera shake. To do this, add another FSM component to your camera object, and create this state machine.

What this one does is cause a quick shake effect on your camera that runs for around half a second, and then it reverts the camera to the default rotation. This last step is important, because the camera remains in its post-shake rotation when the camera shake ends, and that means that, after too many shakes, your camera be looking in a completely different direction instead of aiming at your player.

Use a "lives" system.

Imagine that, instead of getting a game over when you hit an obstacle, you only lose one "life" and you get a game over only when you deplete all of them. If you change your obstacle detection state machine a little, you can use a counter to keep track of how many times you've hit an obstacle, and go to a game over only when that specific amount has been reached.

Another thing you could do is create another kind of coin that gives you an extra "life" so you can recover any lost lives at any point in the game.

The image below shows a basic counter that you can use to keep track of hit obstacles. On the other hand, I think the "life" item is something I'll leave to you.

I'll just give you a tip, it's almost the exact same thing, with the exception that you must "subtract" from the hit amount. 

Sections: Tips + Tutorials

This website uses cookies to ensure you get the best experience possible More Info
Got it!