Defining physics

Hello,

I have defined the player physics like this:

[Player]
Position = (0, 0, 0)
Scale    = 1
AnimationSet = PlayerAnimationSet

[PlayerAnimationSet]
Texture = avion_sheet.png
FrameSize = (64, 64, 0)
PlayerIdle = 2
PlayerMoveFast = 2
StartAnim = PlayerIdle
Pivot = center
Body = PlayerBody

[PlayerBody]
PartList        = PlayerBodyPart
Dynamic         = false

[PlayerBodyPart]
Type            = box
Solid        = true
SelfFlags = hero
CheckMask = ufo

With [Physics] / ShowDebug at true, i don't see neither the physic debug shape, nor coordinates axis.

That's odd, because with simpler objects (ufos which have no animations, body defined in the object entry) , i can see the physic shapes.

[Ufo]
Graphic = UfoGraphic
Body = UfoBody
Pivot = center

[UfoBody]
PartList        = UfoBodyPart
Dynamic         = false

[UfoBodyPart]
Type            = sphere
Solid       = true
SelfFlags = ufo
CheckMask = ufo # hero

And it gives that:

I'm not sure where i should define Physics.
I tried to define Body in [Player] but with a box type, it raises an assert (no assert with sphere, strangely). Anyway, i see only coordinates axis in this case, not the debug shape.

Thank you for reading :smile:

Comments

  • Are you seeing any warning message about this when running in debug by any chance?

    In any case, lemme venture a guess. :)
    As you do not define any dimensions for your body part, orx will then look at the object's Graphic in oder to select one automatically based on the Graphic's side. However, your plane doesn't have a Graphic. I think that is the root of your issue.

  • Thank you for the answer.

    I have no messages in debug, but as you know, i'm using Nim so maybe there is less verbosity in debug.

    I tried to add TopLeft and BottomRight to bodypart, with no visible change (i tried with full and then with a vector, but that doesn't change).

    [Player]
    Position = (0, 0, 0)
    Scale    = 1
    AnimationSet = PlayerAnimationSet
    
    [PlayerAnimationSet]
    Texture = avion_sheet.png
    FrameSize = (64, 64, 0)
    PlayerIdle = 2
    PlayerMoveFast = 2
    StartAnim = PlayerIdle
    Pivot = center
    Body = PlayerBody
    
    
    [PlayerBody]
    PartList        = PlayerBodyPart
    Dynamic         = false
    
    [PlayerBodyPart]
    Type            = box
    Solid       = true
    SelfFlags   = 0x0002 ; defines the identity collision flags for this box.
    CheckMask   = 0xFFFF ; with who this box will collide (collision mask that will be testing on other objects)
    ;TopLeft = full ; on peut mettre un vecteur pour plus de précision
    ;BottomRight = full ; idem remarque TopLeft
    TopLeft = (0,0,0);
    BottomRight = (1,1,0);
    
  • Mmh, the lack of warning message with a debug build is going to make your life difficult in the future.

    Regarding TopLeft and BottomRight:

    • you cannot use full without a graphic/size as orx has no mean to retrieve this information (that's the default settings, btw)
    • you need to use vectors that will be large enough for Box2D to create a physical shape (1x1 pixel, as in your example above, won't be enough with the default DimensionRatio setting)
  • Thank you the time you've spent on this. As we have discussed on Discord channel too, i post the solution you've found for getting physics applied to the plane:

    [Player]
    Position = (0, 0, 0)
    Scale    = 1
    AnimationSet = PlayerAnimationSet
    Body = PlayerBody
    
    [PlayerBody]
    PartList        = PlayerBodyPart
    Dynamic         = false
    
    [PlayerGraphic]
    Texture = avion_sheet.png
    TextureOrigin = (0,0,0)
    TextureSize = (64,64,0)
    
    
    [PlayerBodyPart]
    Type            = box
    Solid       = true
    SelfFlags = hero
    CheckMask = ufo
    TopLeft = (-32,-32,0);
    BottomRight = (32, 32, 0);
    
    [PlayerAnimationSet]
    Texture = avion_sheet.png
    FrameSize = (64, 64, 0)
    StartAnim = PlayerIdle
    Pivot = center
    
    [PlayerIdle]
    TextureOrigin = (0,0,0) ; begins at 0,0
    TextureSize = (128,64,0) ; and plays the first two frames: 64*2,64
    KeyDuration = 0.3
    

    Now that all is set correctly in the ini, i have just to find why the physics events are not triggered :)

  • My pleasure! Glad it's working now. :)

Sign In or Register to comment.