Changing gravity to a only one point on the rope
Hello, it me again
I was wondering if there is a way to add more gravity to one point of the rope, so we can give the illusion of the player weight on the rope
this is my question, thanks in advance
Not possible out of the box. What exactly is your use case?
You can hook the NativeRopeServer.on_pre_update signal and manually shift the point by gravity_direction * custom_gravity * physics_delta.
You can also look at the walk_on_rope example how a RopeHandle is used there for a similar purpose.
I will try your method
this is my use case by the way:
Ah, then the walk_on_rope example is very likely what you're searching for.
well, I have tried a lot of solution and it didn't work
and I didn't like walk_on_rope example
so if possible, I have a feature request which is :
- to add the ability to change the gravity of a single point on the rope
Will not happen, because it's too application specific and easy to implement oneself.
I gladly help you to get it working but I need to know
- what you have tried so far (possibly with a minimal reproduction project)
- what didn't work
- what you don't like about the example
- what you expect exactly (i.e. what do you expect it to look like in comparison to the example)
sorry for taking so long
-
what I wanted to do : I wanted to do this idea which was very simple to do
then I tried this idea and here were I struggled
explanation of it : basically I wanted the rope to go down when you jump on it and the more you jump the more down you go of course simulating this with physics will take ages so I just wanted an illusion
-
what I tried to give the illusion :
- looking for a way to change the gravity of the point that the player is standing on but this is not possible
- there is a property in the rope called
segment_length_distributionI tried get the playerrope_positionand changesegment_length_distributionaccording to it and increase the general gravity to give the illusion but godot curve don't supporte the y cordinate as a varible so it didn't work
- what I don't like about the example : I don't think it workes for me and I didn't understand well it's Mechanic
here is a link to my project if you it has only 4 script only 3 is rope related, if you wanted : https://github.com/Zheromaro/ArrowNight
Unfortunately, I cannot open your project because of broken dependencies.
If I understand correctly, you want a kind of trampoline effect where jumping repeatedly sends you higher and higher while simultaneously pushing the rope further and further downwards. I think the example already brings you halfway there it just misses a crucial piece: transferring the speed of the rope to the player when jumping and likewise transferring the player's speed to the rope when landing. This is actually a bit tricky and I don't know a goodt and simple solution off the top of my head. But I'll think about it and report back.
and I didn't understand well it's Mechanic
The example works like this:
The player object detects ropes using an Area2D. If a rope collision was detected, it will set this rope as target to the RopeHandle which is also a child of the player node. The RopeHandle will be enabled while the player is standing on the rope (when a collision exists) and disabled when jumping or when no collision exists.
The RopeHandle is placed below the player object so it always pushes the rope down. This works because the player will be standing on the rope and if the handle is positioned below the player, it will always be located below the player and thus below the rope. The further the handle is positioned below the player, the more the rope will be pushed down. This effect can be used to give the illusion of weight.
In this case, applying more gravity to a single point will actually have almost the same effect as the handle approach, because they both do the same: pushing a point a little downwards. There might be a slight difference though, I haven't tested it myself.
You can easily test it by just shifting the point according to your desired gravity. Relevant functions are:
Rope.get_nearest_point_index()to get the nearest point indexRope.get_point(),Rope.set_point(),Rope.move_point()to get, set or move positions of a given point index
So essentially in _physics_process() or NativeRopeServer.on_pre_update() you run rope.move_point(index, Vector2.DOWN * custom_gravity * delta.
See also the in-engine documentation for rope related nodes. Most functions are properly documented.
there is a property in the rope called segment_length_distribution I tried get the player rope_position and change segment_length_distribution according to it
Segment length distribution is not useful for this purpose.
It is used to change the length of individual rope segments according to the given curve. This can be used to increase detail at certain areas while decreasing detail in others.
For example, if you know that most motion will happen at the end of the rope and not at the beginning, you can assign a "falling" segment length distribution curve which starts high and ends low so that segments at the start of the rope will be larger while segments at the end of the rope will be smaller, effectively making the rope more detailed with the same point count.
There should be an example in rope_properties.tscn.
thanks for your help
I think Rope.move_point() is promising and very close to what I was looking for
and about the project being broken I think it is because .aseprite file maybe if you delete them it will open but you will not be able to see the player or the coin so turn on collison shap visibility to make things easier
I'll close this issue since the original question has been answered. If you still have questions let me know.