wiln / jiglibflash

Automatically exported from code.google.com/p/jiglibflash
0 stars 0 forks source link

Random outcome when applying a body or world force #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps:
1. Create 2 objects far away from each other using pv3d
2. Convert them to rigid bodies using jiglib
3. Apply a force to one body to direct it towards the other body

Expected: collision
Actual: random... sometimes there is a collision, sometimes it passes next to 
the body without colliding

Mac OS 10.5, Safari, JigLib r108 (not really specific to any revision though)

How to eliminate the randomness in the position update of rigid bodies? I want 
to see the exact same result every time I 
apply a world or body force to a rigid body.

Original issue reported on code.google.com by afil...@gmail.com on 29 Oct 2009 at 9:04

GoogleCodeExporter commented 9 years ago
Are you using the dynamic time step?  maybe you need to use a static time step 
like this: physics. engine. 
integrate(0.1);

Original comment by muzerly on 30 Oct 2009 at 3:22

GoogleCodeExporter commented 9 years ago
I will try and let you know.

Original comment by afil...@gmail.com on 30 Oct 2009 at 3:24

GoogleCodeExporter commented 9 years ago
So physics.step() is not the correct way to go?

Original comment by afil...@gmail.com on 30 Oct 2009 at 3:26

GoogleCodeExporter commented 9 years ago
if you want get the same speed on different fps, physics.step() is correct

Original comment by muzerly on 30 Oct 2009 at 3:36

GoogleCodeExporter commented 9 years ago
After looking at the source, I got a feeling that the fluctuating fps was 
messing with my physics, only didn't 
know that there was a way other than physics.step()

Not a bug.

Original comment by afil...@gmail.com on 30 Oct 2009 at 3:41

GoogleCodeExporter commented 9 years ago
but it doesn't suggest to use the dynamic time step on low fps. because it will 
get the incorrect simulation.

Original comment by muzerly on 30 Oct 2009 at 3:48

GoogleCodeExporter commented 9 years ago
Duly noted. Thanks!

Original comment by afil...@gmail.com on 30 Oct 2009 at 3:54

GoogleCodeExporter commented 9 years ago
A great way to get reliable physics simulation when the FPS fluctuates is to 
time each frame and run physics.integrate(0.1) multiple times depending on how 
many ms has passed since the last frame.  This is a great way to stop objects 
from bouncing around or falling through things when the framerate is low.

Original comment by breakdan...@gmail.com on 16 Dec 2010 at 4:28