Strange physics simulate

edited May 2010 in Help request
; --- Bodies ---

[BallBody]
Dynamic = true
PartList = BallPartTemplate
CustomGravity = (0.0, 0.0, 0.0); NB: If none is provided, world's gravity will be applied to the body;
Mass = 1.0

[BallPartTemplate]
Type = sphere;
Friction = 0.0;
Restitution = 1.0;
Density = 1.0;
SelfFlags = 0x0001;
CheckMask = 0x0001;
Solid = true;

[WallBody]
PartList = Box

[Box]
Type = box
Restitution = 1.0
Friction = 0.0
SelfFlags = 0x0001
CheckMask = 0x0001
Solid = true

when I set ball and wall config like that,all the ball don't bounce as it should be.I don't know why.
but when CustomGravity is set to world gravity as default, all the ball bounced in bottom wall but hardly bounced from left or right walls......that weird....anything I did wrong?

BTW:....sometimes, the ball didn't move at all....I don't know why too.

Comments

  • edited May 2010
    jtianling wrote:
    [BallBody]
    Dynamic = true
    PartList = BallPartTemplate
    CustomGravity = (0.0, 0.0, 0.0); NB: If none is provided, world's gravity will be applied to the body;
    [/quote]

    Here your setting a gravity of (0, 0, 0) for all your balls, so they'll appear as they are floating in space. They will only move if something collide with them (for example, if you spawn another ball very close).
    If you want to use the world gravity, just remove the CustomGravity line. :)
    Mass = 1.0

    This is going to be overridden as the final mass will be calculated by Box2D using all the parts and their densities.
    when I set ball and wall config like that,all the ball don't bounce as it should be.I don't know why.
    but when CustomGravity is set to world gravity as default, all the ball bounced in bottom wall but hardly bounced from left or right walls......that weird....anything I did wrong?

    BTW:....sometimes, the ball didn't move at all....I don't know why too.

    As written above, with a CustomGravity = (0, 0, 0), balls won't move except if they collide and are pushed by other balls.
    If you set a CustomGravity = WorldGravity, the balls should fall downward, isn't it what you experienced?
  • edited May 2010
    Oh, I lost something to post.
    every ball have init speed......

    ; --- Objects ---
    [Ball]
    Graphic = BallGraphic
    Body = BallBody
    Position = (0.0, 0.0, 0.0) ~ (230, 150, 0.0)
    Scale = 0.3
    Alpha = 1.0
    Color = (0, 255, 0) # (0, 0, 255) # (0, 255, 255)
    Speed = (-30, -30, 0) # (30, 30, 0)

    [Balls]
    ChildList = Ball2 # Ball3 # Ball4

    [Ball2]
    Graphic = BallGraphic
    Body = BallBody
    Position = (0, 75, 0.0)
    Scale = 0.3
    Alpha = 1.0
    Color = (0, 255, 0) # (0, 0, 255) # (0, 255, 255)
    Speed = (-30, -30, 0) # (30, 30, 0)


    [Ball3]
    Graphic = BallGraphic
    Body = BallBody
    Position = (75, 0, 0.0)
    Scale = 0.3
    Alpha = 1.0
    Color = (0, 255, 0) # (0, 0, 255) # (0, 255, 255)
    Speed = (-30, -30, 0) # (30, 30, 0)

    [Ball4]
    Graphic = BallGraphic
    Body = BallBody
    Position = (150, 0, 0.0)
    Scale = 0.3
    Alpha = 1.0
    Color = (0, 255, 0) # (0, 0, 255) # (0, 255, 255)
    Speed = (-30, -30, 0) # (30, 30, 0)


    they were not floating in space, they were moving.
    But they didn't not bounced.
  • edited May 2010
    Mass property had puzzled me.I couldn't find it in Box2d manual,But now I know what it means.
  • edited May 2010
    I played a bit with your settings and experienced the same issue as you.

    After a little while I figured out what was going wrong: Box2D doesn't handle well small and big objects. (If I remember correctly on the Box2D page they say objects between 1 meter and 10 meters are the best handled ones.)

    If you try to change the Physics::DimensioRatio in the config files from 0.01 (100 pixels for 1 meter) to 0.1 (10 pixels for 1 meter) everything will bounce correctly. :)

    I'm afraid you'll have to play a bit with Box2D physics settings as I'm no expert with them and I know that a lot of people found it tricky to setup correctly (as seen on various forums on internet).
  • edited May 2010
    Oh my GOD,that's the problem!

    I had read the manual of BOX2d,It mentions the problem,but it just talks about optimization,I didn't think it have so much problem.....

    Thank you very much!I had a lesson...
  • edited May 2010
    Yes, I'm afraid setting up things for Box2D is very tricky. I ran myself into a lot of issues while developping Mushroom Stew. :)

    I even had to hack Box2D to add support for missing features, such as the object-based custom gravity, which is very useful when you want to have both object heavier-than air and lighter-than air. Or when your game includes a gravity gun. :D
  • edited May 2010
    Never be too low-level to be a great programmer.If I want just use orx,I still should know something about box2d,it's nag me.
Sign In or Register to comment.