Open stephanbogner opened 10 months ago
The required code is indeed missing, it does however require the joint to be reconfigured each time as there's no way to update it
@AThousandShips Wow that was a fast reply. Thanks for investigating!
Good to know regarding the reconfiguration. I don't plan to update it dynamically, only to set it once in the beginning according to an exported variable. So at least for me that bug fix would be sufficient and great π
it does however require the joint to be reconfigured each time as there's no way to update it
I do feel it's a little stricter. Maybe we can do something about it, along with some more documentation.
@stephanbogner Take a look at my pr if it solves your problem.
@jsjtxietian Thanks for looking into it! (This also made me compile Godot for the first time π )
Underwhelming screenshot but it works as expected π
https://github.com/godotengine/godot/assets/7897006/cdfdc061-ade5-4ada-aebf-d312ef44e199
extends Node2D
func _ready():
$Right/GrooveJoint.length = 200
await get_tree().create_timer(2).timeout
$Left/RigidBody.apply_central_impulse(Vector2(100, -1000))
$Right/GrooveJoint.set_length(205)
await get_tree().create_timer(1).timeout
$Right/RigidBody.apply_central_impulse(Vector2(100, -1000))
Thank you for your test and congrats to your first compilation of Godot!
- The ball stops down way further than it should and doesn't go up as far (it appears that the joint has been shifted downwards)
- If I apply an impulse it swings which the unchanged groove joint does not (but it doesn't swing when I set it in A)
Upon test, yes that's indeed has these problems, other joint2d's usually have a interface for them to directly change the specific para that are set by user, while GrooveJoint2D do not, everytime you update the para it makes a new one, I guess that's where the problem came from.
However the code has not been changed for a while, and finding the real problem could be more time consuming than it seems.
@jsjtxietian Thanks for clarifying. For me your changes would already be a huge improvement :)
FYI: I did some more tests (that I posted in the pull request) and it looks great.
Hi all, thank you for the contributions!
I will need to modify the GrooveJoint2D's length
during runtime in order to control sail line length in a sailing game. Do you know of any workaround that I could use to get around this problem?
The required code is indeed missing, it does however require the joint to be reconfigured each time as there's no way to update it
Regarding comment above, I may not fully understand the difference between reconfiguration
and update
. Could you clarify?
"Update" here means say to the physics engine "set the length to this", whereas "reconfigure" means "create a new joint with this configuration" π as is explained further here https://github.com/godotengine/godot/issues/85144#issuecomment-1825504765
thank you @AThousandShips.
If I understand this correctly, when this issue is resolved, one could change the length of the GrooveJoint2D by creating new joint with desired length and initial offset and reapply to objects while removing the old joint?
No, that's not it, what I'm saying is that any solution would have to work around it, see the linked PR, this won't change anything from a user perspective (as in you don't have to do anything), just an implementation detail π
ok, you're right, code changes won't solve the update in runtime problem. I think I'll create an issue and try figuring out how to work around it. Thanks for the help!
An issue for what? This issue here is solved by the PR, in runtime
The problem of the joint not being updated is completely solved by this once added, no workaround by users needed, as I said π
Hey guys,
Great job keeping stuff rolling! Any idea when this PR will be merged and released?
Thanks!
Godot version
v4.1.3.stable.official [f06b6836a]
System information
Apple Ventura 13.5, Forward+
Issue description
Setting the
length
of aGrooveJoint2D
doesn't work. The simulated length doesn't actually get updated. It keeps the initially set length.My guess
It seems the joint's parameters are not actually changed, unlike in e.g. PinJoint2D::set_softness.
There is a
pin_joint_set_param
and adamped_spring_joint_set_param
, but nogroove_joint_set_param
. If I can find the time I will try to add this function and integrate it intoGrooveJoint2D::set_length
.Test setup:
Expected result
Both rigid bodies should behave the exact same.
Result
The visualisation of the right groove joint is updated correctly (yellow line), but it doesn't fall lower than the initially specified 50px.
PS: I seem to become the guy that opens all the 2D physics bugs π
Steps to reproduce
GrooveJoint2D
connected to two bodieslength
of the GrooveJoint (neitherlength
norset_length
does work)Minimal reproduction project
groove-joint-bug.zip