I’m trying to achieve a tight rope effect for a 2D game. Think of it like strumming/pulling a stretched out rubber band, guitar string, or bungee cord. Basically, I’m hoping to be able to have several fingers effect and cling onto the ‘rope’ to manipulate it’s shape. and when you release the line it would basically vibrate like you’d expect a tight rubber band would.
I’m not looking for the whole answer(Though that wouldn’t hurt
), just looking for some suggested methods or ideas. So I know where to start researching.
Thanks
How about trying to model the string as a series of springs like so (warning: programmer art ahead):
I’m a little fuzzy on how to handle cases when part of the spring is released while a another is pinned down, but it seems like a reasonable model to start with.
A series of joints and rigidbodies might work…
@shaderop
Yeah, I’ll try something along those lines. I was wondering if you had a any idea how I would make the line visually. Line renderer? Modified Mesh? A bunch of 2D Sprite dots close together.
@xtremepman
I’ve actually tried that in the most simplest sense so far. A series of box or circle colliders with distance or spring joints connect to each other. My issue was that it was rather difficult to control the tension of the string. I played with the Rigidbody settings and the joint distance settings. Plus I wasn’t entirely sure how I would go about drawing/creating a line that followed the Rigidbody. I also actually need the line to have a collision throughout the entire line. instead of little joint collisions.
Anyways so far my latest idea is to use a box collider as a line, and whatever theres a touch, it would split the box collider into two. And then I’d use some joint there with some spring attached…or magnet effect. However for that idea I’m not sure how I would go about drawing a line with that…Especially if I actually want some small curvature to the line when being pulled. Because when you strum a tight rubber band you don’t just see a sharp angle becoming a straight line you see a sharp angle growing into a large curve then into a straight line. I was thinking of using some type of interpolation method but even then I’m not sure if that would achieve what I want.
Anyone else have any recommended methods?