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

Use input override global position if set to calculate diff. #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Boxfort
Copy link

@Boxfort Boxfort commented Jan 26, 2025

Ive made a change to use the input override position to calculate the rope interaction diff if it is set.
As far as I can tell this is a bug?

When the override position is set without this change the CharacterBody2D on that side of the RopeInteraction will be pushed towards the input override position point continuously.

I could also have been using it incorrectly.

@mphe
Copy link
Owner

mphe commented Jan 27, 2025

Thank you for your contribution.
The behavior is not a bug, it's intended to work that way and documented as such:

## (Optional) Use the given node instead of the target node to update the rope point's position.
## If set, the target node will only be snapped to the rope, but it will not affect it.
@export var input_node_override: Node2D

In other words, you can use input_node_override when the node that should snap to the rope and the node that should affect the rope are different. target_node will be snapped, but input_node_override won't.
One use-case is shown in the rigidbody_rope_attachment (and rope_with_rigidbody) example scenes. The rigidbody should affect the rope but we can't just snap the rigidbody to the rope. Instead, a PintJoint2D has to be used.

However, it is not unlikely that you might have found a missing feature.
Could you tell me a bit more about what you are trying to accomplish, possibly with an MRP?

@Boxfort
Copy link
Author

Boxfort commented Jan 30, 2025

Hopefully this is a clear enough explanation of what I was attempting:

image
image

I have a player scene, with a rope as a child. During gameplay I'm attaching the end of the rope to another object to pull it around. I'd like to have the rope originate from the player at a specific point, without having to offset my sprite.

I first attempted to set the Input Node Override on the Start interaction node to the point at which I wanted to rope to originate from on the player, but doing this caused the player to be pulled from the origin of the CharacterBody, towards the point I had specified.

Implementing the change I made meant that the player CharacterBody could still drag using the rope, but the rope originated from somewhere other than the middle of the CharacterBody.

@mphe
Copy link
Owner

mphe commented Jan 31, 2025

I see, this is indeed an oversight.
I can think of two ways to implement that feature:

  • A) Adding an offset property to RopeInteraction which is applied during _on_before_update and _on_after_update. Also the on_movement_request signal should be changed to include the target position as a third argument, now that the computation is more than just a position delta.
  • B) Adding a boolean use_input_override_as_offset (or something similar) property which uses your snapping method when true, otherwise the current one.

B) would be much simpler to implement but I find the input_node_override property already confusing enough. I like A) much better as it's more straightforward usability-wise.
What do you think?

Would you like to update your PR with these changes or should I make a fix?

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

Successfully merging this pull request may close these issues.

2 participants