9
\$\begingroup\$

Struggling to make a decision on the implementation of a ledge climb mechanic for a physics driven 2d platformer. What is the best way to go about this without it getting overly complex?

So far I understand (hobbyist here not a pro) there a few options including:

  1. Apply controlled force to the rigid body on the y axis until the root position is just above the hand position then apply enough force on the x axis so as the character is standing on the platform. At the same time somehow sync this with the climb animation(s).

    Remarks: movement is easy here and can even be controlled by a prismatic sliding joint but I'm unsure of how I would keep the animations (spine) in sync with the movement.

  2. Root motion animation that drives the root position of the character. Teleport the rigid body when complete and hope box2d can still properly respond in time to any collision if any objects happen to fall from the sky.

    Remarks: sounds easier to actually animate but not sure if I'll run into any problems with the spine runtime, box2d or later down the line moving platforms and varied height platforms.

  3. Apply IK constraint programmatically on the hands to lock them in place and proceed to rotate the bones manually or apply small preset (few keys/frames) animations whilst applying the needed force to the rigid body at the same time.

    Remarks: seems like this would give maximum control to the player but it sounds way to complicated for me to implement at my level, not exactly sure where I would start.

Thanks in advance for any input!

FYI: This is an ECS (libgdx + ashley) based engine with box2d. The ledge grab is already implemented as a separate system so we can assume here that the character is already capable of hanging from a ledge of any height.

\$\endgroup\$
0
\$\begingroup\$

you could just move the transform.y up n number of times until the feet are on the ledge and forget the physics temporarily, i think it will work fine, you can always measure the distance between falling objects and the player in case collision fails during a transform translation. to make sure a collision occcurs..

\$\endgroup\$
0
\$\begingroup\$

If the player is pressed against a climbable object then allow up/down to move it on the Y axis. During this state ensure it cannot move on the X axis. As you move you can call Animation.Sample on your climb animation to ensure the point in the animation matches the distance climbed rather than trying to time everything.

\$\endgroup\$
0
\$\begingroup\$

i believe you need more design choices here before you can make a proper decission, specifically, what can happen to the character while he is hanging/climbing?

since you said the game is physics based i asume that you might have a rock falling on your head while either hanging or climbing, so if this is the case i believe going for rootmotion might be the simplest solution, you just need to animate the climbing, while it's climbing it's in a slightly different hanging state, the only difference being that you cannot initiate the climbing action.

Now this is assuming you have the whole hanging situation under control, meaning that if while you are hanging and any interaction happens, the character reacts properly.

Then all you need to do is to set your character's state back to idle once the climbing animation is complete.

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.