## Fast Rope Physics for bump.lua?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Gunroar:Cannon()
Party member
Posts: 284
Joined: Thu Dec 10, 2020 1:57 am

### Fast Rope Physics for bump.lua?

Hello there. I'm looking for help with coding a rope and rope physics that doesn't use love.physics and that can be attached to 2 objects which cause the rope to be pulled and the object to pull one object in a similar way. I've seen other implementations but does anyone have an implementation that can do this.
The pulling should be realistic(damping? I'm not sure how it works) and also stop when the object being pulled is behind a wall/obstacle.
Check out Dust
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
for x, enemy in ipairs(self.allEnemies) do
self:Cannon(enemy)
end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow

MrFariator
Party member
Posts: 243
Joined: Wed Oct 05, 2016 11:53 am

### Re: Fast Rope Physics for bump.lua?

You could do this with bump, but I think you'd honestly be better off using love.physics/box2d for any realism. After all, bump.lua's README even says:
bump is not a good match for:

- Games that require polygons for the collision detection
- Games that require highly realistic simulations of physics - things "stacking up", "rolling over slides", etc.
- Games that require very fast objects colliding reallistically against each other (in bump, being gameistic, objects are moved and collided one at a time)
- Simulations where the order in which the collisions are resolved isn't known.
The first three points are pretty relevant for rope physics, and maybe 4.

However, if you want more gameistic ropes? Sure, bump should work fine. Maybe illustrate an example of what the rope system needs beyond damping.
4vZEROv
Party member
Posts: 124
Joined: Wed Jan 02, 2019 8:44 pm

### Re: Fast Rope Physics for bump.lua?

Sound like inverse kinematics

If it look like what you want I can try to find the code.
pgimeno
Party member
Posts: 2614
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Fast Rope Physics for bump.lua?

T2R uses a simple rope, with just 1 segment, to attach the ball; feel free to check the source code (see sig). If you want a more realistic behaviour (catenary effect, for example) then the plot thickens.
Gunroar:Cannon()
Party member
Posts: 284
Joined: Thu Dec 10, 2020 1:57 am

### Re: Fast Rope Physics for bump.lua?

I kind of just want the object to be dragged by another object, like their in tug of war, but with no extra stuff like yoinking due to gravity.
4vZEROv wrote: Sun Mar 14, 2021 6:04 pm Sound like inverse kinematics

If it look like what you want I can try to find the code.
This seems like it might work, can you find the code?
pgimeno wrote: Sun Mar 14, 2021 7:11 pm T2R uses a simple rope, with just 1 segment, to attach the ball; feel free to check the source code (see sig). If you want a more realistic behaviour (catenary effect, for example) then the plot thickens.
Yes, the plot thickens
Last edited by Gunroar:Cannon() on Mon Mar 15, 2021 7:58 pm, edited 1 time in total.
Check out Dust
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
for x, enemy in ipairs(self.allEnemies) do
self:Cannon(enemy)
end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow

pgimeno
Party member
Posts: 2614
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Fast Rope Physics for bump.lua?

Gunroar:Cannon() wrote: Mon Mar 15, 2021 8:56 am Yes, the plot thickens
If you want pre-made code you can check this project for example: viewtopic.php?f=5&t=12330

If you want to know what you're doing, I suggest you take a look at this post: viewtopic.php?p=219275#p219275 (maybe you need to read some earlier posts for context).

Basically, a rope can be modelled as a series of springs attached to each other, similar to the image here: https://en.wikipedia.org/wiki/Wave_equa ... ke%27s_law so you would use Hooke's law to adjust the position (for each spring in the rope, correct the position of the mass at the end, by applying a force proportional to the distance difference from the "default"/"relaxed" distance). You need to use Verlet integration and make multiple passes. You also need to apply gravity to each mass for the catenary to form itself.
Gunroar:Cannon()
Party member
Posts: 284
Joined: Thu Dec 10, 2020 1:57 am

### Re: Fast Rope Physics for bump.lua?

Nice, I'll look into those thoouugh...I really want my rope to be simple, like straight lines that only bend when they go around a corner(so you could say the physics part is when it comes down to other objects pushing each other. That's why I wanted it done in bump .The "rope" should bends only when it goes around a corner.
That's why I found it hard to use the normal algorithms I already found(plus its for top down use, so no gravity)...heheh.
So with this said any new ideas, or can it still be done with the other ropes?
Check out Dust
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
for x, enemy in ipairs(self.allEnemies) do
self:Cannon(enemy)
end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow

RNavega
Citizen
Posts: 75
Joined: Sun Aug 16, 2020 1:28 pm

### Re: Fast Rope Physics for bump.lua?

You could port some Verlet engine into Lua, the rope would consist of several linked segments (like 100 total), each with a distance constraint.

There are tons of live Verlet physics demos online using HTML5:
- https://subprotocol.com/system/tree.html
- https://codepen.io/guerrillacontra/pen/XPZeww
- https://codepen.io/CLMcCorkle/pen/vrxrgE

Plus this Love2D reference (thanks to GloryFish):
https://github.com/GloryFish/love2d-verlet-cloth
pgimeno
Party member
Posts: 2614
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Fast Rope Physics for bump.lua?

Gunroar:Cannon() wrote: Mon Mar 15, 2021 7:57 pm Nice, I'll look into those thoouugh...I really want my rope to be simple, like straight lines
Now I'm lost about what you want exactly, as this contradicts the ropes forming a catenary and all that.

Gunroar:Cannon() wrote: Mon Mar 15, 2021 7:57 pm that only bend when they go around a corner(so you could say the physics part is when it comes down to other objects pushing each other. That's why I wanted it done in bump .The "rope" should bends only when it goes around a corner.
Bump only handles rectangles, specifically axis-aligned ones. I don't think a rope can be modelled as an axis-aligned rectangle.

Gunroar:Cannon() wrote: Mon Mar 15, 2021 7:57 pm That's why I found it hard to use the normal algorithms I already found(plus its for top down use, so no gravity)...heheh.
So with this said any new ideas, or can it still be done with the other ropes?
Maybe a drawing will help understanding what you want. From your description, this is the picture that comes to my mind:
Boxes-with-rope.png (488 Bytes) Viewed 1961 times
where the boxes are always axis-aligned.
Gunroar:Cannon()
Party member
Posts: 284
Joined: Thu Dec 10, 2020 1:57 am

### Re: Fast Rope Physics for bump.lua?

pgimeno wrote: Tue Mar 16, 2021 1:53 pm
Maybe a drawing will help understanding what you want. From your description, this is the picture that comes to my mind:

Boxes with rope

where the boxes are always axis-aligned.
Yeah! Exactly like that. I didn't want the rope to be in the bump world, just to manipulate the ones it's attached to, and to be drawn. So any idea how to do it?
Check out Dust
me: I don't always code but when I do it's done flawlessly.
also me:

Code: Select all

 function Gunroar:Cannon()
for x, enemy in ipairs(self.allEnemies) do
self:Cannon(enemy)
end
end

Code: Select all

Lua Error: [file Gunroar.lua]:18: C stack overflow


### Who is online

Users browsing this forum: No registered users and 8 guests