Fast Rope Physics for bump.lua?

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

Fast Rope Physics for bump.lua?

Post by Gunroar:Cannon() »

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.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 509
Joined: Wed Oct 05, 2016 11:53 am

Re: Fast Rope Physics for bump.lua?

Post by MrFariator »

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.
User avatar
4vZEROv
Party member
Posts: 126
Joined: Wed Jan 02, 2019 8:44 pm

Re: Fast Rope Physics for bump.lua?

Post by 4vZEROv »

Sound like inverse kinematics

I've made some prototype that look like that: https://twitter.com/4v0v_/status/1334771338020593666

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

Re: Fast Rope Physics for bump.lua?

Post by pgimeno »

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.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Fast Rope Physics for bump.lua?

Post by Gunroar:Cannon() »

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

I've made some prototype that look like that: https://twitter.com/4v0v_/status/1334771338020593666

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 :rofl:
Last edited by Gunroar:Cannon() on Mon Mar 15, 2021 7:58 pm, edited 1 time in total.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Fast Rope Physics for bump.lua?

Post by pgimeno »

Gunroar:Cannon() wrote: Mon Mar 15, 2021 8:56 am Yes, the plot thickens :rofl:
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.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Fast Rope Physics for bump.lua?

Post by Gunroar:Cannon() »

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 :rofl: .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?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
RNavega
Party member
Posts: 239
Joined: Sun Aug 16, 2020 1:28 pm

Re: Fast Rope Physics for bump.lua?

Post by RNavega »

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
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Fast Rope Physics for bump.lua?

Post by pgimeno »

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 :rofl: .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
Boxes-with-rope.png (488 Bytes) Viewed 5322 times
where the boxes are always axis-aligned.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: Fast Rope Physics for bump.lua?

Post by Gunroar:Cannon() »

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?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests