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

Rope that pulls on staticbody2ds #10

Closed
ProbablyIdiot opened this issue Jun 25, 2024 · 10 comments
Closed

Rope that pulls on staticbody2ds #10

ProbablyIdiot opened this issue Jun 25, 2024 · 10 comments

Comments

@ProbablyIdiot
Copy link

Hello,
I've been working on a game where there are two players that are connected by a rope. The players are made up of StaticBodies and can move independantly of each other. What I need help with is making the rope pull on each player, or at least limit the movement, instead of just creating a gap (video attached as zip, as it is too big).
RopeBound (DEBUG) 2024-06-25 12-09-41.zip

@mphe
Copy link
Owner

mphe commented Jun 25, 2024

First thing you should do is change the StaticBodies to CharacterBodies (or KinematicBodies in 3.x). This has nothing to do with this plugin but is a general rule of thumb. StaticBodies are used for static geometry. If they move, they usually shouldn't be static.

Now to the problem:
What you are planning won't work at the moment. There is no way to fixate the rope at the start AND end point. That means the player at the end of the rope will always be pulled towards the other player, but not the other way round.
Getting a grabbing and pulling logic to work in the first place is a little complicated to explain without example.

I will try to get back to in the next few days, maybe end of the week, depending on whether I find some time.
It's been on my list for a while to finally upload a rope grabbing example project.

Also, #9 is slightly related regarding how RopeHandles work and why the gap appears.

If you just want to limit movement, you could also just add a restriction to your player movement code that doesn't allow the player to move further than a certain maximum distance from the other player.

@ProbablyIdiot
Copy link
Author

Thanks for the info, I probably won't be able to get back to you soon, as I have become ill. Thanks againa though.

@mphe
Copy link
Owner

mphe commented Jul 3, 2024

Small status update: I'm currently working on making rope endpoint behavior more configurable. That means an option whether the beginning and/or ending should be fixed or loose.
This should make your use-case possible to achieve. I will also try to include an example project.

@ProbablyIdiot
Copy link
Author

@mphe , Sorry for not replying, I've been completely caught up in school tests. I think I'll take the advice on using CharacterBodies and wait for the update. Thanks for the work you do!

@mphe
Copy link
Owner

mphe commented Jul 15, 2024

So did you already solve it or did you gave up?

@ProbablyIdiot
Copy link
Author

@mphe Im just going to wait for the update you mentioned, the game I’m making is just to learn more about the engine, so I’m doing other projects in the meantime.

@mphe
Copy link
Owner

mphe commented Jul 16, 2024

I'll reopen then until it is solved.

I've been working on an efficient way to completely fixate points and also an option to detach the rope's beginning from the node's position.
You can try out on the endpoint_fixation branch or download a build from the latest build workflow.
The new version also includes much more example scenes.

I'll also try to get a rope pulling example working this week and add it to the project.
The overall setup will be:

  • fixate_begin = false on the Rope
  • Two RopeHandles at the beginning and end of the rope with strength = 1.0
  • Two RopeAnchors at the beginning and end of the rope.
  • A script that connects to the RopeHandles on_before_update signal and sets the position to the respective CharacterBody position
  • Connect to the RopeAnchors on_after_update signal and set the position of the CharacterBodys to the anchors position, preferabily with a move_and_slide to prevent the objects from getting pulled into terrain.

@mphe mphe reopened this Jul 16, 2024
@mphe
Copy link
Owner

mphe commented Jul 22, 2024

I added another node RopeInteraction that handles mutual interaction between a target node and a rope.
There are two examples included: rope_swinging.tscn and rope_pulling.tscn that demonstrate how it can be used.
The rope_pulling example demonstrates your use-case.
You can get the current preview version from the latest build workflow.

Let me know if you have any questions or if you find any issues.
I'm planning to merge the branch into master and create a new Asset Store release by the end of the week if everything works fine.

@ProbablyIdiot
Copy link
Author

@mphe I’m on holiday rn, and I forgot to sync tthe latest version of my project to git before I left, so I can’t test now.

@mphe
Copy link
Owner

mphe commented Jul 23, 2024

Closed by #12.
If you find any issues, feel free to use the issue tracker.
I'll create an asset store release in the next days.

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