This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

I'm making a wheel that can stick to walls and ceilings (in 2D), for that I apply force to the wheel towards the wall. I've tried two ways of doing this (both are used within _integrate_forces function because I need the wheel's "state" to detect contact point):
A: _apply_central_impulse function. The code looks nice, but Godot docs insist that I use impulse functions only for single impacts, "use the “_force” functions otherwise", they say.
B: setting applied_force equal to some value. This makes my code a bit awkward because I have to manually reset it every time I want the wheel to fall. And force still needs to be recalculated every time because wheel should roll along the walls which are curvy.
The behavior seems to be pretty much the same in both cases.
So the question is, what actually is the difference in physics between force and impulse (apart from that impulse value should probably be multiplied by delta) and why is it recommended not to use impulse for long-time forces? Because I would rather use impulse in my case
Also, is there a way to use delta and state in one function? When exactly is _integrate_forces called?
OR maybe everything is way easier and Godot has sticking to surfaces feature implemented in its engine?

in Engine by (42 points)

1 Answer

+2 votes

applied_force applied over time(over frame)
impulse applied once set
both affect physics attribute of rigidbody

analogy:
applied force is like gravity
impulse is like force that you apply in jump, or shoot, or bounce

for A, you insist apply impulse over time, in your case(wall sticking) the calculation error /or performance over time is not much, so you get what you get. in other case (which is more complex). this may cause error calculation or performance issue .

CMIIW

by (22 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.