best way to implement rope/ladder climbing in 2D platformer

I’ve gotten my sprite sheet based character to move around no problem and it collides with the platforms just fine.
I have the collision with the rope/ladder working just fine too.

The next question is how to stop the character from falling and ‘attaching’ it to the rope/ladder. I’ve tried pausing the physics engine and manually moving the character’s y co-ordinates while on the rope. However, this stops all other physics based activities.

My next thought was a static physics object created on the fly as the collision happens and creating a joint between the player and the object. Then manually move the y co-ordinates of the object and the player should follow.

Any better ideas? [import]uid: 9035 topic_id: 9184 reply_id: 309184[/import]

Simple wait for a collision between the sprite and the ladder but only fire the function for the collision if the player is pressing the up button. [import]uid: 12041 topic_id: 9184 reply_id: 33979[/import]

I did just that and the collision occurs (using print() statements to debug)
When I create a new joint between the ladder and the sprite Corona’s simulator crashes. (already reported as a bug) [import]uid: 9035 topic_id: 9184 reply_id: 34163[/import]

Sounds like you are creating the joint during the event handler of a collision event. Start a very short timer (1 millisecond) and in it’s function create the new joint.

The problem (at least it sounds like it) is that you are trying to manipulate the locked physics objects. That always throws exceptions. [import]uid: 8271 topic_id: 9184 reply_id: 34247[/import]

I’ll give that a try when I get home. Hopefully the Corona staff looking at the bug report will come to a similar conclusion. Mind you, I shouldn’t be able to crash the simulator that easily. [import]uid: 9035 topic_id: 9184 reply_id: 34266[/import]

I’m afraid it’s a well known issue and one that is documented as part of Box2D, I believe. Think of it as development time support rather than a bug. The rule is: don’t modify physics objects, joints or properties in response to a physics event because the box 2d engine locks objects during that time. [import]uid: 8271 topic_id: 9184 reply_id: 34300[/import]

@alwzn4vr,
I have not tried it myself, but just something off the top of my head.

  1. Why do you not change the player once on the ladder/rope to a kinematic object rather than a dynamic object, that will prevent the player sprite from falling

  2. To make the player move, try applying a linear velocity in the y axis to push the player sprite upwards.

If these work, good for you, I might give it a try later when I can get a breather.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 9184 reply_id: 35622[/import]

Great idea, I’ll give that a try. [import]uid: 9035 topic_id: 9184 reply_id: 35626[/import]