Bug / Crash gravity does not apply when I manually set the fixed delta time - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Bug / Crash gravity does not apply when I manually set the fixed delta time (/thread-3268.html) |
gravity does not apply when I manually set the fixed delta time - lufydad - 10-01-2022 Hello, When I set the fixed delta time from script to 1/60 in an empty scene with just a rope, the rope just stay still, the gravity does not seem to apply on it. If I change the fixed delta time to another value the rope falls down normally. I use Obi 6.2, Unity 2021.2.4f, and DX11. Is there something that I can do to fixed this ? RE: gravity does not apply when I manually set the fixed delta time - josemendez - 10-01-2022 (10-01-2022, 11:17 AM)lufydad Wrote: Hello,Hi! Just set the solver's sleep threshold accordingly. This is the minimum kinetic energy above which particles are allowed to move. If you reduce the timestep, the kinetic energy during a single timestep will also be reduced, preventing any particle whose energy is below the threshold to move. See: http://obi.virtualmethodstudio.com/manual/6.3/obisolver.html You can set it to zero if you want particles to move regardless of how much energy they have. Note this may result in positional drifting/jittering. RE: gravity does not apply when I manually set the fixed delta time - lufydad - 10-01-2022 (10-01-2022, 11:30 AM)josemendez Wrote: Hi! Thank you a lot it seems to work, when I reduce the sleep threshold In my application the fixed delta time is entered by user, which sleep threshold should I use to be sure to not have this problem anymore and avoid drifting and jittering ? dt/10 is enough ? RE: gravity does not apply when I manually set the fixed delta time - josemendez - 10-01-2022 (10-01-2022, 11:35 AM)lufydad Wrote: Thank you a lot it seems to work, when I reduce the sleep threshold Allowing your user to set an arbitrary fixed delta time is a recipe for terrible performance, but assuming you're not concerned by this: You could use the smallest value that works with the smallest delta time you allow. Or instead of using a very small threshold (which may not be enough for very small timesteps), you can calculate the value you need for a given timestep. Kinetic energy is defined as 1/2 * sqr(velocity) * mass. In Obi, the threshold is mass-normalized, so not multiplied by mass. Velocity is defined as change in position over time. In Unity, this "time" is the timestep (aka fixed delta time) value. So: Code: velocity = (position at the end of the timestep - position at the start of the timestep) / timestep. Hence, kinetic energy is: Code: 1/2 * sqr((end position - start position) / timestep). This is the value compared to your sleep threshold to determine if a particle can move or not. To make the threshold independent of timestep, you can do: Code: timestepIndependentThreshold = sqrt(threshold * 2) * timestep; And then feed this value to Obi instead of a fixed threshold. RE: gravity does not apply when I manually set the fixed delta time - lufydad - 10-01-2022 (10-01-2022, 11:48 AM)josemendez Wrote: Allowing your user to set an arbitrary fixed delta time is a recipe for terrible performance, but assuming you're not concerned by this: You could use the smallest value that works with the smallest delta time you allow. Thank you for taking the time to explain. If I may ask one last question, I don't understand the last equation of your post. Is "threshold" in the equation the member sleepThreshold of obi solver ? RE: gravity does not apply when I manually set the fixed delta time - josemendez - 10-01-2022 (10-01-2022, 02:43 PM)lufydad Wrote: Thank you for taking the time to explain. Hi! "Theshold" is the (time-dependent) input threshold you want to use, this is a value you set. The equation outputs a time-independent threshold, which is the one you feed to the solver's sleepThreshold. So the equation sits in between your hand-picked threshold value, and the one fed to Obi. RE: gravity does not apply when I manually set the fixed delta time - lufydad - 10-01-2022 (10-01-2022, 02:44 PM)josemendez Wrote: Hi! Ok, then suppose I input 0.001 for the sleepThreshold at the beginning of the simulation and the user input 1/60 for the fixedDeltaFrame, then using your equation : Code: timestepIndependentThreshold = sqrt(0.001 * 2) * 1/60 = 3.33*1e-5 I should put the sleepThreshold to this value, is this correct ? RE: gravity does not apply when I manually set the fixed delta time - josemendez - 10-01-2022 (10-01-2022, 02:56 PM)lufydad Wrote: Ok, then suppose I input 0.001 for the sleepThreshold at the beginning of the simulation and the user input 1/60 for the fixedDeltaFrame, then using your equation : Yes, that should work. RE: gravity does not apply when I manually set the fixed delta time - lufydad - 10-01-2022 (10-01-2022, 02:59 PM)josemendez Wrote: Yes, that should work. Great !! Once again, thanks a lot RE: gravity does not apply when I manually set the fixed delta time - josemendez - 10-01-2022 (10-01-2022, 03:06 PM)lufydad Wrote: Great !! Once again, thanks a lotYou're welcome! |