Cliff-hanging in platformers
by Eero Karvonen · in Torque 2D Beginner · 03/04/2014 (10:28 am) · 6 replies
Hi,
have any of you implemented a cliff-hanging feature in your Torque games? I'm experimenting with different approaches on that.
At the moment, I'm transforming the character into a non-moving kinematic body when "cliff-sensor" shapes collide with a platform. But this is not reliable enough, since (even though defined as bullet) the character body will transform at different positions in relation to the cliff edge depending on the incident angle and speed.
Have you come up with any solid working implementations?
have any of you implemented a cliff-hanging feature in your Torque games? I'm experimenting with different approaches on that.
At the moment, I'm transforming the character into a non-moving kinematic body when "cliff-sensor" shapes collide with a platform. But this is not reliable enough, since (even though defined as bullet) the character body will transform at different positions in relation to the cliff edge depending on the incident angle and speed.
Have you come up with any solid working implementations?
#2
03/04/2014 (10:50 am)
Thank you. That kit, however, seems to be proprietary information and specifically for 3D.
#3
Unfortunately I'm not that much into the 2D world yet, so I can't give you a good implementation.
03/04/2014 (10:54 am)
Oh sorry, I'm so used to answering T3D questions LOL. My bad.Unfortunately I'm not that much into the 2D world yet, so I can't give you a good implementation.
#4
When you transform the body, you transform the box also.
They also would act as triggers in order to detect edges.
03/05/2014 (1:00 am)
Hitboxes ?When you transform the body, you transform the box also.
They also would act as triggers in order to detect edges.
#5
03/05/2014 (6:42 am)
Collision shapes don't have to be boxes - you can use circles or arbitrary convex polyhedrons. And objects can have more than one. So your player could have a small-ish circular sensor and the edge trigger could be a medium circular sensor - when they intersect do the transform. This would mean that your player's distance from the cliff edge would always be the same regardless of angle. You can always scale the transform animation based on current velocity setting the sprite's animation playback time (set using AnimationAsset::setAnimationTime()).
#6
imagebin.org/297397
1. Character is falling towards the edge trigger. (Or jumping from below.)
2. When the character's sensor and the edge trigger collide, the character transforms into a kinematic body. Immediately, moveTo() would be called to isocenter the both circle sensors (or some coordinates tuned on that basis) to always move the body to the right position. This phase would also incorporate the animation velocity setting - or even choosing different animations depending on whether the character is jumping upwards to reach the edge or falling down, toward it.
3. The character is in the right position, waiting for further actions: letting drop or climbing up.
Now, the climbing part seems to be more complicated. I'm thinking of first creating a character-sized mask object at the character's position which,
1. first tries to move horizontally towards the platform, unless already moved for the character's width. If impossible, then,
2. move upwards a little bit (unless already moved upwards for more than about 1.2 x character's height; otherwise abort algorithm and don't climb). Then repeat 1.
This algorithm also takes hills into account. Oh, and of course, after the algorithm has finished successfully, teleport the character to the destined position, and for the enemies' bullets and camera's sake, create in the initial hanging position a camera-attached object which uses moveTo() during the animation.
03/05/2014 (10:22 am)
Richard, I developed your idea a bit further and came up with the following,imagebin.org/297397
1. Character is falling towards the edge trigger. (Or jumping from below.)
2. When the character's sensor and the edge trigger collide, the character transforms into a kinematic body. Immediately, moveTo() would be called to isocenter the both circle sensors (or some coordinates tuned on that basis) to always move the body to the right position. This phase would also incorporate the animation velocity setting - or even choosing different animations depending on whether the character is jumping upwards to reach the edge or falling down, toward it.
3. The character is in the right position, waiting for further actions: letting drop or climbing up.
Now, the climbing part seems to be more complicated. I'm thinking of first creating a character-sized mask object at the character's position which,
1. first tries to move horizontally towards the platform, unless already moved for the character's width. If impossible, then,
2. move upwards a little bit (unless already moved upwards for more than about 1.2 x character's height; otherwise abort algorithm and don't climb). Then repeat 1.
This algorithm also takes hills into account. Oh, and of course, after the algorithm has finished successfully, teleport the character to the destined position, and for the enemies' bullets and camera's sake, create in the initial hanging position a camera-attached object which uses moveTo() during the animation.
Torque Owner Lukas Joergensen
WinterLeaf Entertainment