I got my hands on Verlet Integeration, so I created this

2D Gui Based Ragdoll using Verlet Integration


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!

https://www.roblox.com/games/7470238300/Verlet-Integration-Ragdoll

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.

Thanks,
jaipack17

9 Likes

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

1 Like

How did you make OBB collision detection or are you?

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!

that’s actually smart idea, to create fake OBB.

1 Like

Did sebastian lague’s newest video inspired you?

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!

2 Likes

Yeah, but you should add value, how much the stick can handle
Just for the future.

local n = 0
local function WaitEveryN(N)
      n+=1
      if (n>=N) then
           n = 0
           wait() 
      end
end

Makes iterating much faster

1 Like

Better visualization of how I fake elastic OBB Collisions using verlet integration:

One more thing that impresses me is turning position into a rotation.
How do you do that?
https://www.roblox.com/games/7013228050/Tankster-2D
https://www.roblox.com/games/7217415823/Agent-2D

So here, using two points, I find the angle between those two vectors!

Here’s a visualization:

Here’s some pseudocode:

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

And then, I just rotate the frame by that theta!

Check this out:

2 Likes

Thank you!
I always wanted to understand this part of math :slight_smile:

1 Like

Can you make the game open source? I’m really interested in how you made it!

People playground remake please?

There are a few things I need to fix and make my code optimal, I’ll surely do so after I feel confident about my code!


:smirk:

2 Likes

Send me a DM of the game if you make it :wink:

2 Likes

This is really awesome, I’m sure some great games could be made with this!

Thats what I immediately thought of when I saw this post lmao
I’d love to play it if you actually make the game @OP

1 Like