Limited lives, respawn and display

How to create limited lives, a respawn and display lives remaining

When creating a game you may want the player to have a set number of lives before they die completely.

For this you will need a respawn system, and a life variable, and a life display.

This tutorial show you how to do all of these things.

Life variable

In your hero brain add:

WHEN [once] DO [numvar:lives][=][3] (or how ever many lives you want)

Displaying the lives remaining
You have various options for this.
You can show the number of lives
WHEN DO [display][text: LIVES: ][numvar:lives][screen top right]

You can show a meter
WHEN DO [display meter][numvar:lives][screen top right]

You can use the display counter
WHEN DO [display counter][numvar:lives][screen top right]

You can use an object or icon
WHEN [for each of][numvar:lives] DO [display][heart][screen top right][HUD stack right] (you may also want to change the scale of the display object, as they can be quite large)

There are lots of options for life an health displays, too many to list.

Respawn

When your player dies you need to be able to revive him and take away one of his lives. Go into brain properties and set destroy after death to off.

WHEN [started to][is dead] DO [boolvar:dying][=][true]

Now you can choose to revive him where he stands, or move him to a respawn point. This is normally a logic cube or ancient stone landmark prop.

WHEN [boolvar:dying] DO
…WHEN [countdown timer][3] DO
…/…WHEN [started to]
…/…/WHEN DO [position][=][IWP:respawn point][position]
…/…/…WHEN DO [numvar:lives][decrement by][1]
…/…/…WHEN [until][numvar:lives][equal to][0] DO [revive]
…/…/…WHEN DO [boolvar:dying][=][false]
WHEN [numvar:lives][equal to][0] DO [boolvar:dead][=][true]
WHEN [boolvar:dead] DO …. //here is where you put the instructions for your game over. These could be the words Game Over, a bit of music and a game over tile. You could display a score. You could return them to the start menu. It is up to you.

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: