Falling
Hey all, working with my 2D Sidescrolling Platformer, and I'm having trouble being able to tell when my character is falling? Is there any easy way to be abe to do this?
You'd think it would be a really easy concept, but the way I have the game set up right now it might be a bit hard..
Let me know if I'm missing something
~Thanks
You'd think it would be a really easy concept, but the way I have the game set up right now it might be a bit hard..
Let me know if I'm missing something
~Thanks
When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Code:
if(yvelocity <0)
isFalling=true;
Well then. I feel intelligent. Thanks.
When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
skyhawk Wrote:Code:
if(yvelocity <0)
isFalling=true;
Correction...
Code:
if(yvelocity <0)
isFalling=true;
play_sound("Ahhhhhhhhhhhhhhhhhhhhhhhhh_*splat*.mp3");
Jones Wrote:Correction...If you're going to be silly, your code would play that sound regardless of whether I am falling or not.
Code:
if(yvelocity <0)
isFalling=true;
play_sound("Ahhhhhhhhhhhhhhhhhhhhhhhhh_*splat*.mp3");
I'm assuming what you actually were asking about was how to tell when your character has stepped off the edge of a platform?
What I do is keep a boolean that indicates that my character is standing on something. Every cycle, I apply gravity and run collision detection. If your standingOnSomething variable was set to true but you don't detect a collision from the bottom of the character, they've just stepped off the edge of whatever they were on.
What I do is keep a boolean that indicates that my character is standing on something. Every cycle, I apply gravity and run collision detection. If your standingOnSomething variable was set to true but you don't detect a collision from the bottom of the character, they've just stepped off the edge of whatever they were on.
ThemsAllTook Wrote:I'm assuming what you actually were asking about was how to tell when your character has stepped off the edge of a platform?this doesn't mean they are falling.
What I do is keep a boolean that indicates that my character is standing on something. Every cycle, I apply gravity and run collision detection. If your standingOnSomething variable was set to true but you don't detect a collision from the bottom of the character, they've just stepped off the edge of whatever they were on.
skyhawk Wrote:ThemsAllTook Wrote:I'm assuming what you actually were asking about was how to tell when your character has stepped off the edge of a platform?this doesn't mean they are falling.
What I do is keep a boolean that indicates that my character is standing on something. Every cycle, I apply gravity and run collision detection. If your standingOnSomething variable was set to true but you don't detect a collision from the bottom of the character, they've just stepped off the edge of whatever they were on.
if you have stepped of the edge and you are not falling, the only possibility is that you havent noticed yet.. see roadrunner for examples.
Sir, e^iπ + 1 = 0, hence God exists; reply!
ThemsAllTook Wrote:I'm assuming what you actually were asking about was how to tell when your character has stepped off the edge of a platform?I jump, thus I was on the platform, and now I am no longer on a platform. I am not falling. There is a possibility I will fall though.
What I do is keep a boolean that indicates that my character is standing on something. Every cycle, I apply gravity and run collision detection. If your standingOnSomething variable was set to true but you don't detect a collision from the bottom of the character, they've just stepped off the edge of whatever they were on.
aka, stop using a hack and use the code that is ALWAYS correct.
But when you jump, you are falling. You just have positive velocity for a short period of time. So the algorithm does detect if he's "falling," it just doesn't say whether he's moving up or down. It still tells you he's not standing on a platform.
My Game Dev Page:
http://whindgames.50webs.com/
StressFracture: http://www.sourceforge.net/projects/stressfracture
skyhawk Wrote:aka, stop using a hack and use the code that is ALWAYS correct.Thanks for jumping to conclusions and assuming that I don't know what I'm doing. I really appreciate it. Sarcasm aside, that comment was inappropriate and unnecessary. Please make an effort to be less abrasive in future posts.
Jumping is handled differently. I simply didn't mention it in my above description.
Quote:if(yvelocity <0)
isFalling=true;
Quote:aka, stop using a hack and use the code that is ALWAYS correct.
With all due respect, I think ThemsAllTook's is much less of a hack (if at all). Say I'm sliding down a slope - with your approach, it would look like falling because my y velocity is less than zero; with his approach, I know I'm not falling because I landed on a slope and haven't left it.
Norelius Wrote:With all due respect, I think ThemsAllTook's is much less of a hack (if at all). Say I'm sliding down a slope - with your approach, it would look like falling because my y velocity is less than zero; with his approach, I know I'm not falling because I landed on a slope and haven't left it.True, if you are handling slopes differently than ledges you would want to use some kind of boolean to track whether the character is falling. In the simple games I made, I had no such distinction so I just checked whether the y component of velocity was less than zero, it is simple yet effective.
skyhawk Wrote:I jump, thus I was on the platform, and now I am no longer on a platform. I am not falling. There is a possibility I will fall though.
aka, stop using a hack and use the code that is ALWAYS correct.
What about getting your idea, and getting ThemsAllTook's one and &&'ing them.
That way you can go downward on an elevator and not be falling, and you can also be at the start of a jump and not be considered falling.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Falling snow | Blacktiger | 2 | 3,177 |
Nov 26, 2007 01:09 PM Last Post: Duane |
|

