what does drag = 1
even mean?
#424
-
I was tweaking the physics of my platfomer and found myself setting Looking in kaplay/src/components/physics/body.ts Lines 23 to 28 in 37c8d67 My understanding is that if the drag is 1, this means that the object will be able to be pushed, but it will not continue to slide after it stops being pushed. This follows from the docs' equation: plug in drag = 1 and you get But the code actually does kaplay/src/components/physics/body.ts Lines 408 to 409 in 37c8d67 If drag = 1 is used in the current code's equation, and the frame rate is say, 60fps, then the equation becomes I tried putting in values larger than 1 for drag, and this does make the object stop faster, but it has caveats: if I use drag = 20, and then the game lags and the frame rate drops below 20fps, then the equation becomes (if the frame rate is currently 12fps) It would maybe be more clear if |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Drag is old Kaboom code which still needs to be fixed. It's actually damping, since drag would be through a medium, and depend on geometry. Damping is a ratio, so it should be this.vel.x *= 1.0 / (1.0 + this.damping * k.dt()); The physics framerate is always 50fps, regardless of the display framerate. |
Beta Was this translation helpful? Give feedback.
-
Well, yes, but usually damping between 0 and 0.1 is used. If you want
something to stop instantly, just reset the velocity.
…On Fri, 4 Oct 2024 at 08:10, dragoncoder047 ***@***.***> wrote:
OK, that makes more sense... so if I want it to stop instantly I just have
to use damping = Infinity. (that is, once this is fixed).
—
Reply to this email directly, view it on GitHub
<#424 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHIYWZ6VOOTJ4WEYF2IXKLZZXFGLAVCNFSM6AAAAABPJ557J6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOBTHAYTQNA>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Kind Regards,
Marc Flerackers
Software Engineer
|
Beta Was this translation helpful? Give feedback.
-
I know, but I don't think damping is something you change in order to stop an object from moving at certain moments in time. And if it is always at infinity, the object won't move when forces are used on it. |
Beta Was this translation helpful? Give feedback.
-
Yes, I'm adding friction and restitution to the area component (to be
compatible with other physics engines) once I have time.
…On Fri, 4 Oct 2024 at 08:47, dragoncoder047 ***@***.***> wrote:
I guess I'm looking for friction then...
—
Reply to this email directly, view it on GitHub
<#424 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHIYW5WZMCEOI2FV5Z5E7TZZXJQBAVCNFSM6AAAAABPJ557J6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOBTHAZTENY>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Kind Regards,
Marc Flerackers
Software Engineer
|
Beta Was this translation helpful? Give feedback.
-
@dragoncoder047 Can you check the restitution branch? |
Beta Was this translation helpful? Give feedback.
Drag is old Kaboom code which still needs to be fixed. It's actually damping, since drag would be through a medium, and depend on geometry. Damping is a ratio, so it should be
this.vel.x *= 1.0 / (1.0 + this.damping * k.dt());
this.vel.y *= 1.0 / (1.0 + this.damping * k.dt());
The physics framerate is always 50fps, regardless of the display framerate.