I'm using a custom platform engine. How do I kill the player if he's fallen too far down the screen? I can't use an active on the ground to kill the player because he needs to be able to walk across the same ground.
Printable View
I'm using a custom platform engine. How do I kill the player if he's fallen too far down the screen? I can't use an active on the ground to kill the player because he needs to be able to walk across the same ground.
You can try this: when the player's animation "falling" is playing, at 1 to a hidden counter for every 1/4 of a second, or whatever. When the player's "stopped" or "walking" animation is playing, and if the counter is over a certain point, kill the player. Otherwise, just set to counter to 0. This what I did in one of my games, "Flight to Freedom". I hope this helps.
Thanks andy, I'll give that a try.
That doesn't work andy. I think because my player has custom movement and not the default Clickteam platform movement.
I have a fake player that follows the real hidden player. Animations for the fake player are set in conditions.
The image below shows the conditions and events for the animations of my custom movement. I somehow need to add a condition that plays a falling animation but I can't get one to work.
http://i33.photobucket.com/albums/d9...ps8iwnjjbk.png
How about adding it to when the player isn't touching a backdrop? That's the same as falling, right? Every 1/4 second the player isn't touching a backdrop you could increase or decrease a counter that if the condition is met the player is killed? That's unless you expect the player to be airborne safely for more than the timed counter. or you might need to get fancy that while the player is not touching the backdrop if the difference betwen the extreme -Y value exceeds whatever number of the +Y when landing, the player dies. That would require some additional thinking to put in.
While that does appear to work and could be worked into a fall damage model, the counter still increases while standing on active objects such as the moving platforms, ladders, springs and other active objects I have with various gravity conditions (such as jelly blocks that make the player bounce wile walking on them).
I'd have to set conditions for all of them to reset the counter to 0.
This is what I've got set up at the moment.
"Detector" refers to the 1 pixel high purple line under the active that is my character for detecting when on backdrops. See image above. The player is the yellow active with the detector underneath.
Condition: Detector is overlapping a backdrop --> Event (counter): Set Counter to 0
Condition: Detector is NOT overlapping a backdrop --> Event (counter): Add 1 to Counter [every 00"-45]
Condition: Counter >2 AND Detector collides with the background --> Event: Subtract 1 from Number of Lives (and respawn).
While normal jumping the counter only reaches 1. With double-jump it reaches 2.
When falling, the counter reaches 2 or 3 depending how high the fall is but the player doesn't lose a life when he hits the ground.
I only lose a life if I remove the "AND Detector collides with background" condition. But this means I die while just jumping.
have you ever played around with limit conditions? What if you create another event for whenever you are overlapping the backdrop and limit the condition to only once when the condition loops, then set the timer to 0. This should zero it out for whenever you need to jump and land. Sorry, in the middle of something and wanted to post this before getting back to it.
No, I can't figure it out. Might have to think of another way that doesn't use counters. Or abandon the whole project, pointless making it if the player isn't killed when falling too far.
Well that's not cool. Can you share it over a drop box or something if i sign a non-disclosure agreement? :)
There's a few ways to accomplish this, actually.
Correct me if I don't understand though, the only time the player is falling is when not overlapping a backdrop? If that's the case you can totally use the limit condition fairly easily. Remember, the timer should only increment while either jumping or not overlapping the backdrop. That's 1 event. A separate event is when either the 'jump' ends, or when the player touches a backdrop. That event gets limited once because it's an infinite loop. As soon as that happens, the timer gets set to 0.
Another way (and maybe easier to wrap your head around) is using a flag or variable. When jumping or not overlapping, set a flag on the player to 'on' or set a variable you create on the player to 'on'. The next event is when the flag is set to on or the variable equals a certain value, increment the time by 1. When the player lands or touches a backdrop, you set the flag 'off' which stops the counter and then you also need to set the counter to 0.
Using the limit condition is really useful in this case. It really helps you get around crazy programming issues when you end up in infinite loops.
Ok, I had time to grock what you have so far. Your code should kill the player if the counter is 3+ and the detector touches the backdrop. Removing your AND would kill the player in mid air (which I'm sure you don't want to do). Are you sure the detector has the ability to touch the backdrop? Maybe the player is touching the backdrop but the hotspot of what you have detecting is never able to make contact? That sounds like what is happening. I have a feeling if you turn on the debugger, your counter never stops increasing.Quote:
This is what I've got set up at the moment.
"Detector" refers to the 1 pixel high purple line under the active that is my character for detecting when on backdrops. See image above. The player is the yellow active with the detector underneath.
Condition: Detector is overlapping a backdrop --> Event (counter): Set Counter to 0
Condition: Detector is NOT overlapping a backdrop --> Event (counter): Add 1 to Counter [every 00"-45]
Condition: Counter >2 AND Detector collides with the background --> Event: Subtract 1 from Number of Lives (and respawn).
While normal jumping the counter only reaches 1. With double-jump it reaches 2.
When falling, the counter reaches 2 or 3 depending how high the fall is but the player doesn't lose a life when he hits the ground.
I only lose a life if I remove the "AND Detector collides with background" condition. But this means I die while just jumping.
Why not forget the detector and just use the player? Otherwise, make sure the detector is actually able to touch what you need it to. I can't say more without looking at your objects.
Also, your first condition is an infinite loop so your program is constantly setting the counter to 0. It works but uses up processing. This is a good part to add the limit on loop to the condition.
Thanks Jarred. There are obviously a number of ways to accomplish what I'm trying to do - it's just finding the solution that fits. So with that in mind I'll PM you my mfa so you can have a look.
EDIT
I've also got David Newton taking a look, I used his platform engine. I thought I could add fall damage if the falling animation was playing for too long and then stopping (colliding with backdrop) but couldn't figure out a way to add falling to David's engine.
Thanks to DavidN the fall damage model now works. Adapt this to David's Fastloop Platform engine - obviously the following is primarily for my platform game so it would need some tweaking to get it working for your own games.
Add fall damage counter to Grav:
http://i33.photobucket.com/albums/d9...ps3jw9hooy.png
Create the max counter to kill player when colliding with backdrops and to reset to zero when not falling or hitting actives:
http://i33.photobucket.com/albums/d9...psws87zuqh.png
In this example it just plays a sound effect for being killed.
Hopefully this will be of benefit to others who want fall damage in their platform games.
All credit goes to DavidN.
Yep, I did the same exact thing. While the guy is in the air (or not overlapping a backdrop) you add to a counter, and if he IS overlapping a backdrop and that counter is >= to whatever # you feel is right, kill the guy or make him take damage. I would sort of suggest not having the fall outright kill the player, as it might be tough to determine just how far you can safe fall during a game. (IMO of course)
You might use a timer (Time X object for example). When the player is falling, the timer starts. When the player stops falling, you stop the timer and check its value and decrease the player's health if needed. Then you reset the timer. You might need a flag to check if the player is falling, or use the same condition you use to play a 'falling' animation (if you use one).
That's a good idea, soopytwist!
There's a problem.
It seems you can negate fall damage by moving left or right just before hitting the ground after a long fall. This is bad.
I ran my game at a frame rate of 10 and the fall counter reached just over 300 (the player is supposed to be killed at equal to or greater than 180 when hitting a backdrop).
Moving left or right just before impact seems to cancel out the fall damage - even though the counter is at 300 when hitting a backdrop!
Anyone got any ideas?
Okay. I found the cause. It's not the fall damage per say, it's my detector for detecting slopes and starting the slopes loop that's cancelling out the fall damage.
http://i33.photobucket.com/albums/d9...psp2hsq59d.png
19, if the "Set Counter to 0" is not added to the On loop "Slopes" then the counter increases as the player walks up and down slopes (with the falling sound too). Unfortunately this also cancels out fall damage when the detector for slopes (the thin red line) collides with a backdrop BEFORE the collider of the player - by about 2 pixels!
If I remove the fall counter reset event from the slopes loop then at least the player dies properly when hitting a backdrop but that leaves the fall counter to increase when walking on slopes.
The only solution I can come up with right now is to silence the falling sound while on a slope and since the fall counter is hidden it shouldn't matter - unless the player is walking on slopes for a long time, in which case they will suddenly die for seemingly no reason when walking off the slope onto a flat backdrop!
Sorry for the late post. I hope you haven't given up on your game, as I know how it feels to get stuck (I currently am). :s
Anyways, what you need to do is place invisible "floor" sensors over every platform. Perhaps in a separate layer with a box that represents the player's collision box and have that follow the player using "Set position to (0,0) from Active. Then, when that collision box is overlapping one of your floor sensors, set a flag or variable that indicates that the player is touching the ground.
When that collision box is not touching the floor sensors, you could use the method mentioned by Andy to add to a counter, and when the player's collision box collides with the floor sensors (while travelling in directions 31-17 to avoid head-smashes on ceilings) and the counter is above a certain amount, kill the player.
It sounds a bit messy, I know, but this is the best way with the least exceptions that I can think of.
DavidN's example works best. Creating actives on every platform would be suicidal in my game. Not only would it take literally months but would significantly slow the game down with all those actives everywhere!
I solved the problem by creating an active only on large sloping platforms (there aren't that many). While the player is overlapping these the fall counter is zeroed rather than zero the counter in the Slopes loop. The only draw-back is making sure the level design does not allow falling to death onto slopes but that's easy to deal with. At any other time falling to over 180 on the counter kills the player when hitting a backdrop, which works fine.
I see. I'm glad you were able to find a solution - My post from yesterday is still unresolved :s
Good luck with your game!