-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Update PinJoint2D API with angle limits and motor speed #81610
Update PinJoint2D API with angle limits and motor speed #81610
Conversation
Took the motor part from here: https://github.com/slembcke/Chipmunk2D/blob/master/src/cpSimpleMotor.c As I understood, the whole physics api now uses parts from chipmunk physics engine, which seems to be right. Still need to write impl for calculating initial angle between objects. Right now the limits are for angle difference, but it works. Screen.Recording.2023-09-13.at.19.55.13.movAlso, one small issue is the angular limits seem to be kinda soft, not 100% sure why. Let me know what you think. |
We should add a reference to
And add it just before the line |
2d6a66e
to
9877f31
Compare
Fixed the above issue, implemented feedback, review again and it's ready for merging I think, from my side at least. Works also same with implementation in box2d, well, almost (most notable difference is in box2d limits are harder, while with this implementation it seems limits are a bit softer). |
888e40e
to
21fb91a
Compare
21fb91a
to
0ded9c0
Compare
Node properties are more commonly called godot/scene/2d/physics_body_2d.cpp Lines 1038 to 1041 in 5f1e56f
|
0ded9c0
to
c55bef9
Compare
Thanks for the idea, very good naming scheme. I like it better. Updated. Also, angular_limit sounds a little bit weird. Should it be angular_limits? |
c55bef9
to
39baabd
Compare
aee7298
to
0889b55
Compare
0889b55
to
e4167dc
Compare
add enabled methods for motor and angular limits use correct name to get joint update copyright
e4167dc
to
0fcfb07
Compare
Thanks! |
Thank you! |
Why is it a soft limit? Is that intentional? When I think of limits I expect it to be a hard limit (like a hinge) |
The code was taken from another physics engine that was initially used in Godot Physics 2d, chipmunk physics engine. And there it is implemented like that. I am not really an expert in 2d physics so working with an already implemented solution was easier. I have added though in this PR also the licensing and the link where it was taken from. If you want hard limits, in box2d for eg. they have hard limits. I guess it depends on the physics engine and how it's implement? If not we can think of adding another parameter that specifies how hard/soft are the limits? |
This is definitely a good step. Thanks for your contribution. I'm also not a physics expert but I needed it for a client project. I'll take a look how it's implemented in box2d. Physics is always super finicky |
In the box2d one the angle limits are not yet implemented as this was just merged. |
I think adding another parameter for the stiffness of the limits would help to provide both soft and hard limits |
With which torque does it drive the joint? |
For the angle limit or for the motor? Also the code is taken from the chipmunk engine, as can be seen, so I'm assuming it's similar to that. |
I meant for the motor. Looks like it can apply unlimited torque. |
I think so. If you want a different case I can make a proposal and add a maxTorque property maybe? |
Right. But actually the motor does not work for me at all. It just does nothing. I have a wheel which is connected to another body but nothing happens if I set motor_enabled to true and motor_target_velocity to 100. What could be wrong? |
Can you try this project that I tested this PR with and see if that works for you and try to work from that? |
Also I'm not sure if this kind of help support discussion should happen here, as this PR is closed already. If you need anything, open a new godot proposal or ask on discord or on chat or on forum better. This way it won't notify the main devs also. |
Closes: godotengine/godot-proposals#7646