# How can I make an infinite rope?

The idea is that I want a rope wrapped around my Main character, and when he runs around the rope infinitely grows behind him until he gets to tethers where he ties it and then the rope grows, again, infinitely from him (rinse and repeat).

I want the rope to be able to interact physically with the world.

I’m struggling with knowing what mechanic to use. I was considering a line renderer, and having the player drop cookies(invisible objects) and have the line draw between them, but the line wouldn’t accurately wrap around trees and what not, so I don’t like that idea.

alternately, I was considering this method I’m reading about using hinge joints and making a string of rigid bodies, but that sounds incredibly cumbersome.

I’m absolutely sure someone has already sweat this question to a much greater length than I have, hoping to barrow that brain!

Thanks,

There would be 4 things in my mind you would want to deal with: the mesh, the texture of the mesh, and bones along the mesh. The fourth thing would be collision, but with procedural generation collision is always the bottleneck.

Making a crap load of game objects attached to each other wouldn’t be a great solution, but it would be the most naive and simple implementation. I would try it and see how far you could go with that first. Sometimes the easiest ( aka “greediest”) solution is the best solution. So always go for the greedy solution when possible, and if it doesn’t work, go for a more thought out solution.

The optimum solution for procedural rope is gonna have to be procedural generation. You extend the mesh at the attach point as the player walks away from the attach point. You might optimize this by pooling and culling (have extra rope mesh hiding inside of another mesh, likewise you can’t actually have an infinite rope, but you can make it really really long - at some point it will be culled).

You can add bones to the mesh to give it that droopy/elastic physical look. You might want to add bones at the split points, or just have several along the mesh. The finer the granularity of the bones, the better the rope is going to look. Idk any concrete optimizations here, but LOD for the bones (disable the bones as the player walks away) might be doable.

The final thing is texturing it. You can tile a texture at runtime for this. You can mipmap/LOD the texture, etc, for optimization.

Baking collision is a bit more costly. You may literally have to create a new collider every time the player draws new rope. That’s why you’d want to pool some rope. Runtime collision deformation is really intense in terms of performance, which is why you don’t see stuff like that. A good implementation of this might be looking at the cloth manual. Alternatively, you could look at some research articles and implement collision + runtime deformation on your own, or even buy an implementation from the asset store. But thats another bag of potatoes my man. Again, doing some simple LOD for far away rope might be optimium. Disabling the furthest rope pieces would probably save a lot of frames. Any player would prefer these tricks (that might cause funny little bugs) to lagging out!

EDIT: To clarify, you would add collision to the bones, and generate a collider at the bone (probably a sphere because it’s cheapest). the rope would have a rigidbody, so the bones will act physically. you can then have a physics material on the rigidbody and those colliders should act appropriately.

I wouldn’t actually make it infinite, I would make it some set distance, then just move it towards the player so long as they don’t know the difference. Having anything in a game that is possibly infinite is logically flawed (of course).