Swimming underwater with limited air

How to create a limited air feature for your underwater swimming characters

Your player can swim underwater, but he is not a fish. He has limited breath holding abilities. This kode combined with the underwater swimming brain will give you limited air. Your character will die if he stays under the water too long. Make sure you have a respawn system in place.

Instructions

Please see this tutorial for the Underwater Swimming brain ( the video also shows this addition to the underwater swim brain – it uses a call page to add this kode)

Add  as childlines to the boolean “dive”

WHEN [started to] DO [numvar:air][=][100]
WHEN DO [numvar:air][decrement by][0.1]
WHEN DO [display meter][numvar:air][above][scale][0.3]
WHEN [numvar:air][less than][20][and][air][greater then][0] DO [play sound][Human Male panting]
…WHEN DO [play sound][Human Heartbeat fast]
WHEN [numvar:air][less than][0] DO [kill][me]

You can change the amount of air he has either by altering the start level or making the decrement number smaller.

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: