Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to animate a rope/string. What's the best approach for this? #7

Open
kevinlu1248 opened this issue Jul 27, 2021 · 4 comments
Open

Comments

@kevinlu1248
Copy link

Exactly as stated in the title. I'm thinking about making it like a chain, using some constraints, but add smaller and more segments. Is this a viable approach? Thank you for all your work thus far.

@pdcxs
Copy link
Collaborator

pdcxs commented Jul 29, 2021

It is not an easy task to create a rope in all physics engines. To the best of my knowledge, the only way to simulate rope is using joint segments/springs. The following links may be helpful:
Stackoverflow: How to create rope
pymunk joint document

@kevinlu1248
Copy link
Author

As an update on this, I actually do have something functioning, although it does have quite a bit of overhead and it has some strange rippling effects. Further, it can move through objects when moving too fast. I will send a video later showing this.

@kevinlu1248
Copy link
Author

kevinlu1248 commented Jul 29, 2021

Brief example of a point trying to run away while leashed to two nails.

IntroPuzzle.mp4

@kevinlu1248
Copy link
Author

kevinlu1248 commented Jul 29, 2021

It's basically a chain:

video-1627443070.mp4

But then every frame I get a spline interpolator to smoothen the curve:

video-1627452168.mp4

At the moment, I'm facing a few issues with this implementation:

  • Getting the beginning and end of the curve to have equal slopes (can't find a good algorithm to smoothen/interpolate a 2D closed curve)
  • Slow render times when I place the beginning and of the chain too close together although t
  • Too jittery; not too sure what causes this but decreasing the damping parameter helps significantly.
  • Like any object, moving too quickly causes this to move through obstacles
  • I also don't know how to make the rope stretchy. I tried making the tension adjustable but it causes some really strange behaviour...

On the other hand this method does produce a decent rope without too many chains at a reasonable level of performance. I can do a PR if your interested in having this in your library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants