Earlier today, I got my hands on Verlet Integration, Verlet integration is straight up amazing for physics in games. Its widely known by many developers. So, I went ahead to watch a few videos and read a few articles to create this Ragdoll using Verlet integration and Guis!
There are points for each joint of the ragdoll, these points are always connected with line segments (Gui Frames), these points move according to each other and the length of each line segment. The points can be held with the mouse and can be used to drag the ragdoll here and there.
Verlet integration is truly magical, you should surely check out its working since you can create amazing stuff that includes physics when developing games or computing graphics! The next step for me is to create a controllable active ragdoll! It will be amazing to use it to create a 2D Stickman fighting game using guis!
Feedback, suggestions and queries are always welcome! I would love to answer your questions regarding this creation.
wow thats so cool i wish that the ragdoll mans body part collided with other parts instead of going through them but good work and i like all you gui related posts
So basically, there are different joints, which act as points for the line segments. The beauty of verlet integration helps me out a lot here, Here’s an example of how OBB collisions work in this creation and require no complex math!
In the image above, when the red point collides with the blue wall, a bounce force is applied causing it to reverse it’s velocity’s direction. After sometime, the red point takes the place of the green point, hence a change in the orientation and position of the line segment is seen, which simulates OBB collisions!
I saw that video a few days ago, but the creation that inspired me was a cloth made with verlet integration, and now that I think about it, its so easy to make one!
point1 = Vector2(0, 0)
point2 = Vector2(100, 100)
-- By mental maths, you expect the angle between those points to be 45 degree.
-- Actually finding the angle now:
theta = math.atan2(point1.y - point2.y, point1.x - point2.x)
theta /= math.pi
theta *= 180 -- theta in the form of feasible rotation for the Gui object