confusion on multiplication by delta in _physics_process
Asked Answered
D

2

0

Hi there. I have a function:

apply_torque($CameraPivot.transform.basis.x*rolling_force*delta)

And I'm not sure if I should multiply by delta inside the physical functions or not. Documentation says:

Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.

And for the apply_torque_impulse says:

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).

I wonder if time-independent and time-dependent has anything to do with multiplication by delta. Considering the rolling_force should be 100,000 to make the ball move at a regular speed (in my project), I think the apply_torque function does use delta internally. I need to make sure though...

By the way, I googled the subject, but couldn't find a comprehensive guide on when to use and when not to use delta. If there is any link/explanation it would be great if you share it here.

Thanks a lot

Driscoll answered 3/10, 2023 at 8:38 Comment(0)
T
1

Driscoll In physics, the impulse is defined as accumulation of force in a period of time. Mathematically speaking it's an integral of force with respect to time. From this follows that the numeric approximation in a small time period is indeed: impulse = force * delta_time

So if you know the force and the time slice, you should multiply them when passing an argument to methods that set the impulse. However, if you already know the force, there's actually no need to apply the impulse. Simply apply that force using apply_force(). Obviously in that case you pass only the force vector and let the engine deal with the time.

Same holds true for torque which is a rotational equivalent of force.

Calling impulse methods is really only useful if you're writing a custom physics integrator.

Timpani answered 4/10, 2023 at 14:21 Comment(0)
D
0

Timpani Thanks for the info.

I use impulse for something like jumping which happens only once. I suppose there is no need for delta_time in that case.
However I wasn't sure about the other methods which apply a force continuously.

Driscoll answered 8/10, 2023 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.