# Clientside visual rope physics?

I’m trying to make ropes for my fishing rod but I’m kindof failing at it as I lack knowledge around physics and all that stuff.

http://dl.dropbox.com/u/244444/rope.gif

Here’s the code I have for that:

[lua]
local points = {}

local length = 40

local material = Material(“cable/rope”)
local entity = LocalPlayer():GetEyeTrace().Entity
local gravity = Vector(0,0,2)
local damping = 0.8

for point = 1, length do
points[point] = {position = entity:GetPos(), velocity = entity:GetVelocity()}
end

``````points[1].position = entity:LocalToWorld(Vector(0,0,200))
points[math.Round(length/2)].position = entity:LocalToWorld(Vector(0,100,0))
points[length].position = entity:LocalToWorld(Vector(-100,0,0))
``````

– print(points[50])

``````for point = 1, length do
debugoverlay.Cross(points[point].position, 10, 0.02, color_white, true)
--	for neighbor = 1, 2 do
local position1 = points[math.Clamp(point-1, 1, length)].position - points[point].position
local length1 = math.max(position1:Length(), 1)

local position2 = points[math.Clamp(point+1, 1, length)].position - points[point].position
local length2 = math.max(position2:Length(), 1)

local velocity = (position1 / length1) + (position2 / length2) + (gravity * 0.001)

points[point].velocity = points[point].velocity * damping + (velocity * 0.3 )

points[point].position = points[point].position + points[point].velocity
--	end
end

cam.Start3D(EyePos(), EyeAngles())
render.SetMaterial(material)
render.StartBeam(length)
for point = 1, length do
end
render.EndBeam()
cam.End3D()
``````

end)
[/lua]

Now this isn’t exactly physics (I think ) but I want to mimic keyframe_rope valve has.

What I’m doing in the code is that I’m getting the neighbors position and subtract it by the one in the middle of those two. I do this for all parts of the rope.

So there are two things that are wrong with it.

• First it’s supposed to be like this /\ but it goes like this |\
• The other point is also not attached properly for some reason
• It lacks slack.

[editline]12:33AM[/editline]

I don’t know about collision. I think that would be pretty resource intensive. Or would it?

Updated the code. This works somewhat good, but there are some problems such as the points not spreading out evenly and they’re a bit slow.

I don’t know why no-one has posted here!

This looks awesome. Can I hang myself with these ropes?

Clientside. So, no.

Shame. I wanted to be able to attach the rope to myself, attach it to a wall and then jump off something high and… die?

http://img25.imageshack.us/img25/4936/hangself.png

ITT: Hand-drawn FP logo (terrible I know)

I wish I could do this…

Thanks for sharing…

lol.

what

``````
(User was banned for this post ("Why reply?" - mahalis))

``````

Lolwut
EDIT:
So this is rope that has prop collisions?
Or just responding to velocity?
EDIT:
Thank Garry for the edit button!

:siren:

``````

``````

:siren:

``````
(User was banned for this post ("Why reply? (you have been here way too long not to know not to give these people attention)" - mahalis))

``````

Sorry mahalis :frown:

I dont understand why the guy who said “LOL” didnt get banned, Get your act together mahalis!

And im not sure… but i think ropes ARE client side… Well the visual is but the constraint isnt.