User Tag List

Results 1 to 6 of 6

Thread: Box2D - Colliding with corners of tiles

  1. #1
    No Products Registered

    Join Date
    Jul 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Box2D - Colliding with corners of tiles

    I've started putting together a simple platform game intended to take advantage of Box2D, but it looks like I've come across a pretty basic obstacle early on.

    I'm generating the collision in the world by adding a bunch of tiles placed in the level that have been snapped to a grid. These are added to body 0. A player character (body 1, with rotation disabled) is moved around by applying X force.

    Occasionally, while the player body is being pushed along a smooth surface made up of multiple tiles, it will come to an abrupt halt. This only seems to happen the moment the player body crosses over the next tile. My best guess is that it's technically colliding with a side edge of one of the tiles that make up the ground.

    Is this a problem anyone else has encountered? What is the best way to reliably move a body smoothly over a series of static boxes?

    Thanks!

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Box2D - Colliding with corners of tiles

    Maybe make the base of the character circular in the phizix world?
    Working as fast as I can on Fusion 3

  3. #3
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Box2D - Colliding with corners of tiles

    This is actually a very common problem for people who create tile-based games.

    The best solution I know of is to merge the tiles along the same surface into a single polygon, but this is unfortunately not always possible nor easily implemented. Another solution is to build the static terrain by tracing the borders with line segments/edge chains.

    Making the base of the player a circle works in some cases, but the problem might persist if you have moveable boxes or similar objects where changing the physical shape isn't possible.

    Erin Catto, the creator of Box2D, has this problems on his todo-list, so it will probably be fixed in a future version of Box2D, but for now a work-around has to be used instead.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Box2D - Colliding with corners of tiles

    I have run into the same problem as you Tatsu, and yes the only solution that I've found is the one Werbad mentioned, of combining the surface into a single polygon. It makes it a bit hard for tile based games though.

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Nov 2008
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Box2D - Colliding with corners of tiles

    Is there an easy way to do this (without having to deal with creating a "box2d map" for every level)?

  6. #6
    No Products Registered

    Join Date
    Jul 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Box2D - Colliding with corners of tiles

    Giving the sprites a circular base is a good workaround for me. It makes the characters slide off the edge of a platform, but I actually like that effect.

    Thanks for the advice!

Similar Threads

  1. Travelling Up and Down Walls, Ceilings, Corners, Etc
    By stevenart1988 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 3rd April 2013, 12:57 AM
  2. 2 Dynamic PMO objects colliding?
    By Krim in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 5th June 2011, 07:55 PM
  3. How to collide with corners?
    By MostDreaded in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 2nd January 2011, 02:56 AM
  4. Colliding with Backgrounds
    By Jaffob in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 24th September 2008, 12:29 AM
  5. Detecting collisions without the objects colliding
    By Mantoid in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 18th November 2006, 09:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •