Falling through floor

11 posts

Flag Post

How do I stop my player falling though a floor for them to like move around (platformer)

 
Flag Post

You can use the hitTestObject method to check for collisions between objects. Like this:

if (player.hitTestObject(floor)) {
 if (playerIsFalling) {
    //Stop falling
}
}
 
Flag Post

Or hitTestPoint for a better result non flat terrain (like if you wanted slops this could let the player walk up the slope just fine and if you have a gravity var it will allow the player to walk down the ramp)


while (floor.hitTestPoint(player.x,(player.y+variableForHalfPlayerHeight),true)
{
player.y – -
}

 
Flag Post

I just don’t understand how you stop them falling. Yes you test hitTestObject but how do you keep it up. It’s really confusing me

 
Flag Post
Originally posted by AlexanderC4:

I just don’t understand how you stop them falling. Yes you test hitTestObject but how do you keep it up. It’s really confusing me

Well, that depends of your game. Using a loop (like in evan999333’s post) to lower player’s y until it no longer collides is a good idea, but obviosly you have to adapt it to your game’s parameters (ex: setting the falling speed to 0, letting the player to jump, etc)

 
Flag Post

Are you doing tile-based or just movieclips?

 
Flag Post

what is tile based? its probably movieclips

 
Flag Post

http://www.emanueleferonato.com/2008/09/14/new-tile-based-platform-engine-part-1/
Although some people say this site/persons tutorials are questionable if you are new its a good place to start. Go through the whole tutorial and you will be able to make a platform game.

 
Flag Post
Originally posted by evan999333:

http://www.emanueleferonato.com/2008/09/14/new-tile-based-platform-engine-part-1/
Although some people say this site/persons tutorials are questionable if you are new its a good place to start. Go through the whole tutorial and you will be able to make a platform game.

That’s actually in AS2… I wouldn’t recommend it.

 
Flag Post

There is AS3 version with the AS2

Sorry I just pasted the link but it looks like a good way into the tutorial it switches to AS3

The AS3 starts here http://www.emanueleferonato.com/2008/09/25/new-tile-based-platform-engine-as3-version/

So I guess just read through the first 5 parts and get what hes doing.

 
Flag Post
Originally posted by AlexanderC4:

How do I stop my player falling though a floor for them to like move around (platformer)

You know what needs to be done. You need to detect when the character hits the floor and stop it from falling. Explicitly, with as many lines of code as needed. Nothing will happen by magic. The computer will do everything you tell it to do (and exactly that) but it will do nothing more.