Falling

Member
Posts: 78
Joined: 2004.06
Post: #1
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 Rasp
~Thanks

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #2
Code:
if(yvelocity <0)
isFalling=true;
Quote this message in a reply
Member
Posts: 78
Joined: 2004.06
Post: #3
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
Quote this message in a reply
Jones
Unregistered
 
Post: #4
skyhawk Wrote:
Code:
if(yvelocity <0)
isFalling=true;

Correction...

Code:
if(yvelocity <0)
isFalling=true;
play_sound("Ahhhhhhhhhhhhhhhhhhhhhhhhh_*splat*.mp3");

Wink
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #5
Jones Wrote:Correction...

Code:
if(yvelocity <0)
isFalling=true;
play_sound("Ahhhhhhhhhhhhhhhhhhhhhhhhh_*splat*.mp3");

Wink
If you're going to be silly, your code would play that sound regardless of whether I am falling or not. Rolleyes
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #6
Unless that was Python code... Wink
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #7
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.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #8
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?

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.
this doesn't mean they are falling.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #9
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?

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.
this doesn't mean they are falling.

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!
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #10
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?

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.
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.
Quote this message in a reply
Member
Posts: 30
Joined: 2006.05
Post: #11
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.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #12
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 this message in a reply
Apprentice
Posts: 6
Joined: 2006.10
Post: #13
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.
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #14
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.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #15
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!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Falling snow Blacktiger 2 3,652 Nov 26, 2007 01:09 PM
Last Post: Duane