How to make player die when he falls off a ledge

Hey guys,

I don’t know how to make my player die when he falls off the ledge. I had a vague idea to use extractors but unfortunately, I’ve screwed it up big time. When the player falls off the ledge the camera doesn’t follow but I don’t want that I just want the player to die and restart the level. Please help me.

3 Likes

Just make a block that kills you when you step on it. Put it out of sight in any and every place you intend the player to fall.

6 Likes

This is a good simple solution for a basic game, but I’ve been wondering myself if there is a way to make a player take damage after falling from too high of a height. Like let’s say I want the character to be able to jump 2 blocks high, so falling from 2 blocks shouldn’t deal damage. But if the player falls from 3 blocks high, the player takes some damage, and more damage if they fall from 4 blocks, etc.

Guess I should have made a separate thread for that question, but since they’re both somewhat related questions… I figured that could possibly help both me and the OP.

3 Likes

@TGW and @akshen - one way to do this that I can imagine would be to use the y velocity of a player. So, if they hit a ground block moving faster than a certain speed in the y direction, it would cause them damage. Since the player would likely accelerate when freefalling due to flowlab gravity physics, you could test out what velocities they reach when jumping from certain block heights, then set a cutoff velocity where they would take damage.

Of course, this is more a response to TGW’s post, @camiwami had a good response if all you want is the player to die when they “fall out of the world.”

4 Likes

I did think about testing that, but I’m still new and haven’t played around with gravity enough to know how the physics work.

It’s just a feature I wanted to include in a future game project, I probably won’t be using gravity much in my immediate projects. I do want to eventually know how to make everything work though.

(Sorry, didn’t mean to hijack the thread, I was just curious about falling damage myself)

4 Likes

That worked like magic. simple yet effective. Thanks man and thanks everyone

2 Likes

what camiwami said did the trick for me

2 Likes

What you could do is drag in an inView block from the triggers. Connect a restart level to that and BOOM. Deth.

1 Like

Do what he said but make a checkpoint system. Here’s a replica of what you want to do:

OH YEAH??! WELL…

2 Likes

You made yours complicated for no reason…

Now now, I’m sure both of you are equally good at killing game sprites.

Myself, I’d probably get the coding wrong the first time and the sprite would just be stuck there suffering in agony. Then I’d recode it, and the sprite would die instantly just from looking in the direction of the fatal block. Third time’s the charm! Though at that point, my coding would look like a clumsy person tried juggling a few dozen yoyos.

3 Likes

Yeah… it’s not too complex though… you just extract the player’s position and save it to a save behavior…

Then when the player goes off screen have it read the save blocks.

I’ve slowly come to the understanding of save blocks, and text lists. But I finally mastered both and I can make anything if I put my mind to it with my knowledge.

1 Like

I actually do know how to insta-kill a sprite, that’s easy. Make a death block and set player collision to “restart level”.

More complex would be having a player take damage based on how far the player fell. That’s not something I plan on testing anytime soon though, as most of my next few projects are going to be either top down or “2.5 dimensional” where fall damage won’t really come into play.

2 Likes