Help with One-Sided Platforms

Hello,

In the API Documentation and within the new collision example comments, there is a paragraph that says:

“For example, in a platform game, you may wish to construct “one-sided” platforms that the character can jump vertically through, but only in one direction”

While explaining the preCollision event.

I have been trying EVERYTHING I can think of to implement one-sided platforms where the player can jump through the bottom of the platform and land on the top but I can’t seem to figure it out… so I figured it’s time to consult the forums.

Since the people at Ansca made the examples and wrote the documentation implying it is in fact possible to do, PLEASE explain how this can be done.

So far I’ve tried…

Detecting where the player is in relation to the platform on preCollision and setting .isBodyActive on the platform (or the player) to false IF the player came from UNDERNEATH the platform.

When I do that, the player DOES in fact pass through the platform, but since the body is INACTIVE, the preCollision event does not fire anymore, therefore it never knows when to set the body back to ACTIVE, thus allowing the player to land on top of it…

I felt like I was SO close when I got the player to pass through the bottom of the platform, but then realized I was stuck when he would not land back on top of it, so any help anyone can provide would be GREATLY appreciated.

Thank you very much!

Jonathan Beebe
[import]uid: 7849 topic_id: 1805 reply_id: 301805[/import]

In short, the developer documentation, it says you can use “preCollision” for one-sided platforms to override the collision…

So I’m just wondering HOW to override a collision, so that the player will go through it if coming from the bottom but not the top?

Thank you very much for any help you can provide. [import]uid: 7849 topic_id: 1805 reply_id: 5400[/import]

My guess is, return TRUE in the collision handling event and it will stop reporting.

This I got from the Collision event propagation rules section in the API reference about the collision stuff. [import]uid: 5712 topic_id: 1805 reply_id: 5401[/import]

@MikeHart: I tried returning true, and it DID stop reporting the collision (I was printing to the console) on that one instance but even though the collision event doesn’t fire, the player still bounces off of the platform due to their physical properties (dynamic/static), which is why I tried the isBodyActive route but I was only successful half of the way with that (described in my first post).

Perhaps someone at Ansca can shed some light on how to accomplish this? [import]uid: 7849 topic_id: 1805 reply_id: 5402[/import]

Anyone? [import]uid: 7849 topic_id: 1805 reply_id: 5423[/import]

Sorry to bump this thread but I REALLY need help figuring this one out… It’s probably the first time I’ve actually got stuck with Corona.

Could the Corona devs, preferrably the one(s) who mentioned one-sided platforms in the documentation explain how to do this… please?

Thank you very much,

Jonathan Beebe [import]uid: 7849 topic_id: 1805 reply_id: 5440[/import]

I finally figured it out, and I really think the documentation for postCollision should be modified, because using postCollision, you really can’t do the one-sided platform thing (I’m convinced, and nobody wanted to reply, so I’m thinking nobody else could figure it out either).

This is how I did it for anyone interested, and for the record, it works perfectly. Its about as stable and works just as precisely as Doodle Jump platforms.

First the platforms are sensor objects that use the SAME image as the actual platforms.

The actual platform object is static and is moved off-screen at the start of the game (also has the same display image as the sensor).

The “shape” of the sensor is actually set to be about double the height of the actual sensor object, and that acts as the “post” collision (you can’t actually use the postCollision event with sensors, so you have to simulate it by making the physical shape larger than the image).

When the player “collides” with the sensor (regular “collision” event), he’ll pass through it, and if he’s coming from the bottom, the REAL physical platform does nothing, however, as soon as the players feet passes the sensor image (not the shape, but the height of the image), then the REAL platform’s x and y values change to that of the sensor he just passed.

Since you’re modifying X/Y values, you don’t actually see the REAL platform moving, it just gets placed on top of the sensor the player just passed (coming from the bottom). If the player collides with the sensor’s shape coming from the top, the same thing happens instead of letting him pass through.

That was a big headache, but I’m thankful I got it figured out.

@Ansca: If I can make the suggestion again, PLEASE remove the one-sided platform statement from the “postCollision” documentation because it is very misleading… UNLESS you can please explain how to make a player pass through a platform coming from one side using the postCollision event.

Hopefully this helps some folks out :slight_smile: … If not now then hopefully someday in the future.

I might make an example and submit it to the code section since platform games are very popular and just about every one of them can make use of this.
[import]uid: 7849 topic_id: 1805 reply_id: 5461[/import]

in box2d (as3) it is supposedly quite simple. please can we have this functionality Ansca!
http://www.emanueleferonato.com/2010/03/02/understanding-box2ds-one-way-platforms-aka-clouds/

added feature request (since it’s seemingly already built into box2d)
http://developer.anscamobile.com/forum/2010/12/10/override-contact-precollision-box2d-contactsetenabledfalse

[as3]

override public function PreSolve(contact:b2Contact, oldManifold:b2Manifold):void {


// checking distance between bodies
var distance = player_y_position-platform_y_position;
// if the distance is greater than player radius + half of the platform height…
if (distance>-14.5) {
// don’t manage the contact
// THIS ALLOWS THE PLAYER TO PASS THROUGH
contact.SetEnabled(false);
}
[/as3] [import]uid: 6645 topic_id: 1805 reply_id: 13685[/import]

i am working on a game where where you have to jump onto platforms among other things. Can you tell me how are are jumping? are you using like an impulse or transition.to to achieve the desired effect?

thanks

Larry [import]uid: 11860 topic_id: 1805 reply_id: 13694[/import]

you could apply a force, or if you’re not using physics look around at some old flash tutorials… they might help. the language isn’t too different
http://www.gotoandplay.it/_articles/2004/02/tonypa_p10.php
http://www.emanueleferonato.com/2007/07/03/creation-of-a-platform-game-with-flash-step-1/

actually if you are using physics there’s plenty of flash examples that can help too, and corona’s physics setup is a lot easier.
http://www.emanueleferonato.com/2009/08/07/box2d-platform-engine-alternative/

[import]uid: 6645 topic_id: 1805 reply_id: 13703[/import]