GUI Based Rope Swinging Physics - Tarzan

Rope Swinging Physics

2 dimensional Rope Swinging Physics made with Guis


A few months back, I found a youtube channel. Dani. You may all know who he is by now, he’s a renowned unity game developer and a youtuber. I saw one of his old videos. Where he took up the challenge to develop a game in 30 minutes, and yeah, he did an amazing job. He created a fun little game about rope swinging. You hold onto targets using a rope, you swing high up and try to break as many targets as possible while trying not to fall or hit red targets. Here’s the video, if you would like to watch it:

Alas, back then, I wasn’t much of a 2D game developer, so couldn’t really make it on Roblox. But, 2 days ago, I was just lurking on the roblox website, something in my mind made me search for @boatbomber, and I found one of his games to be quite fun and similar to what Dani had made. This essentially struck my brain and gave me the idea, why not create rope swinging but exclusive of any 3D objects, just startergui?

And then, began my 2 day quest to make this come to life, and now I present to you, rope swinging physics made with guis!


Since this might be a never seen creation before, I’ll be open sourcing it! For you to learn, experiment, use it in your games or what ever in the world you want to do with it!

Showcasing time!

It has smooth inbuilt camera adjustment functionality, smooth physics, visible ropes, accurate target selecting!

You just hold you left mouse button, somewhere close to a pink target, and it selects the nearest target to cling too!


Don’t believe me, doubt that its made with guis or just want to test it out? Here! I uncopylocked the place!


That’s all I have got for today, I hope you enjoy these posts! Feedback, suggestions and questions are always welcome. Feel free to share them!

New to my posts? I do 2D Gui Based game development on Roblox! Check out my other posts here, or go through my profile if you want:

I hope this helps some of you out. Peace!

29 Likes

milk.

Other than that, you can make a satisfying endless game with this (like what he did)

2 Likes

Fancy seeing you here knowing that you were gonna create a physics engine :smirk:

2 Likes

It’s great! But don’t mind me saying so it would be better if you could explain us your step by step procedure? Because it would be helpful for us to learn how you did it instead of us trying to understand it ourselves

Of-course, sorry that I didn’t include it in the post. Its quite a tricky but fun process.

Whenever you hold your mouse button, it finds the nearest pink box from the mouse location. Then I form a rope, which is a gui frame. Using trigonometry I position and rotate it correctly on the screen.

The ball, has a velocity. A gravitational pull attracts the ball down to the bottom of the screen by incrementing the velocity by 0, .1

When the ball reaches the bottom, its velocity’s direction is reversed causing it to bounce.

The most important part of all is the swinging part. What I do is, find the magnitude between the pink box and the ball, and essentially move the ball towards the pink box’s position by adjusting the velocity of the ball to simulate the swinging movement. At a specific point it’ll reach to close to the pink box it starts to apply a harder force to the ball to prevent it from clipping!

Here’s the part where it does that, in the source:

function Tarzan:Swing()
	if not self.lock then return end
	
	local target = self.lock.AbsolutePosition + self.lock.AbsoluteSize/2 + offset
		
	local forceX = (target.x - self.position.x) * xstiffness;
	self.velocity = Vector2.new((self.velocity.x + forceX), self.velocity.y) 
	local forceY = (target.y - self.position.y) * ystiffness;
	self.velocity = Vector2.new(self.velocity.x, (self.velocity.y + forceY))

	self.position += self.velocity
end

That’s just a gist of how I did it, with weeks of practicing, exploring, I was able to figure out simulation of physics using guis, and here I am today!

1 Like

Aweasome😁

Night come in handy in future thank you!

1 Like

Super cool! The ball seems pretty elasticy. It doesn’t fully satisfy the swing effect, at least in my opinion.

Reminds me more of a Spiderman web swinging thing.

Yeah its somewhat like a grappling hook with rope swinging, I bet, in a few weeks or months, I’ll look back at my code, be disgusted for about 2 minutes and then find a better and a natural solution to rope swinging!

How in the world have you created this masterpiece?
Dark magic, I’m guessing
:flushed:

1 Like