Thanks for playing the game!
The stretch detection for Mr Strong is simple, it's just if you triggered the stretch. I don't check the distance although I did at one point but I felt like it slowed the game down so I dropped it.
The actual stretch is a bit more complicated. Using Godot, I created a 2D skeleton and rigged the sprite (its just a single sprite). After I created a dictionary that holds information about the chain of bones for each limb. Next the bones run ithrough an IK system I wrote. The IK system works like this:
- Gets all the limb data from the chain (bone positions, velocities, lengths) and find the root bone anchor point (shoulder/hip)
- Check if the limb is being dragged by the mouse
- If dragging pull the end-point of the bone chain towards the mouse
- Apply damping and update positions based on velocity
- Next I do multiple iterations of the following for stability:
- Ensure each bone maintains its correct length by adjusting connected joints
- Pull bones toward their desired lengths.
- Keep the root bone attached to it's anchor point
Convert the new simulated bone positions into the bone transforms
Workout bone rotations by looking at the direction between joints
Clamp/limit angle changes to prevent some jank
Lerp angle on the rotations for a smoother movement.
I hope that helps with some understanding and direction if you ever try to build your own IK system.