Create an object that collides with everything

edited March 2012 in Help request
Is there a way to create an object that collides with everything? We want to have everything in our game that leaves the bounds of the screen die (its a top-down shooter, off-screen enemies won't do anything but waste ram). How would we set the flags and things to be able to do that?

Comments

  • edited March 2012
    Yes, give him all the SelfFlags and all the CheckMask this way it'll collide with any non-static objects that have non-0 flags/masks:
    SelfFlags = 0xFFFF
    CheckMask = 0xFFFF
    
  • edited March 2012
    Thanks!
  • edited March 2012
    Any screenshots for the "projects" section of the forum? :D
  • edited March 2012
    Not yet... just squares shooting other squares at the moment.
  • edited March 2012
    so we created an object that collides with everything. however, for some reason our objects are not colliding with that object.

    here is how we define the body parts of the objects that are colliding
    [ScreenBorderBodyPart]
    Dynamic   =  true
    Type      = box 
    SelfFlags = 0b1111111111111111 
    CheckMask = 0b1111111111111111 
    Solid      = true
    
    [ShotPart] ; Body Part Box
    Type        = box
    SelfFlags   = 0b0000000000010001
    CheckMask   = 0b0000111111111110
    Restitution = 0.0
    Friction    = 0.0
    Density     = 0.0
    Solid       = false
    
  • edited March 2012
    What dimensions are used for your ScreenBorderBodyPart?
    If you don't set them in the part itself, it's going to use the size of the objects (coming itself from the graphic). If you don't have a graphic on that object, this part actually has a 0-width dimensions.

    I'd check that first and if you use a recent enough version, you can turn on physics debug display to see all the shapes rendered on screen by turning the Physics.ShowDebug config property to true.

    You don't need to set your screen border part as dynamic. Dynamic means its movement can be affected by the collision with other objects, and I don't think you want that.

    So I'd go with Dynamic = false.

    If you need to move that object manually, you can then set AllowMoving = true.

    If your ShotPart is moving fast and your screen body part is too thin, it's possible that Box2D doesn't find the collision (it's a discrete iterative solver, which means movements are not continuous). To fix that, Box2D has an option to allow more extensive checks for fast moving objects.
    You can turn that on in orx with the config property HighSpeed = true on your ShortPart.

    If all this is not working, let me know. :)
  • edited March 2012
    we had for the graphic a pixel that we scaled as a screen delimiter so i'm guessing the hit box for the pixel is too small and it's not covering all the pixel since it was scaled. Thanks for your help i thinking i just have to change the size of the hit box in the pixel.
  • edited March 2012
    The scale will be applied to the shape. However if it's only 1 pixel wide and your ShotPart is also small it's more than probable than Box2D "misses" the collision.

    You can widen your screen border off-screen and that should help. Let me know if you want the problem. :)
Sign In or Register to comment.