Proper Gridless Isometry

0 favourites
  • 6 posts
  • Hello, for reference, here's the classic 2 event isometric solution:

    This is great for any isometric game with objects' collision polygons that are as wide as they are tall, or at least symmetrical along their Y axis. The problem arises on oddly- or diagonally-shaped objects; when an object's Y value is less than the player's, but the player should still be in front of the object:

    The red dot is the location of the Image Point used for calculation.

    Is there any solution that does not involve cutting the object into separate pieces and having each one be a separate sprite?

    Tagged:

  • Best I’ve found is mostly covered here:

    bannalia.blogspot.com/2008/02/filmation-math.html

    The building blocks of that is to compare two objects to see which should be in front. Them you’d sort all the objects with something called a topological sort. You only need to sort the objects visually overlapping each other.

    As seen on that page there are some cases where the the sort will fail, so in those cases it would be good to be able to split the objects.

    That said, depending on your levels, you can design around that to avoid the failing cases.

    If everything is on the ground plane I think it should be possible to do something similar.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So if everything is on the ground plane, and you make your level with all the blocks visually sorted. All that’s left is to move the player as he moves around.

    If each block has two imagepoints like in this image we can sort the player. Basically if they are below the line they are in front otherwise they are behind.

    The event would look like this:

     glabal number x0=0
    global number y0=0
    global number x1=0
    global number y1=0
    
    player overlaps block
    for each block
    -- set x0 to block.imagepointx(1)
    -- set y0 to block.imagepointy(1)
    -- set x1 to block.imagepointx(2)
    -- set y1 to block.imagepointy(2)
    -- compare: player.y<(y1-y0)/(x1-x0)*(player.x-x0)+y0
    -- -- player: move behind block
    -- else
    -- -- player: move in front of block

    Sorting Player vs enemy, npc or other simple objects would be simpler. You’d just compare the y positions.

  • Aha! I knew there was some solution involving multiple image points and somehow utilizing a line between them, but with my limited knowledge of both Construct 3 and geometry I wasn't sure how to articulate that into an Event.

    Hypothetically, more complex objects could be solved with more image points and more conditional math, right? I'm sure at that point breaking it up into multiple objects would be faster.

    Your solution is highly relevant to large simple diagonal stretches of walls/cliffs commonly found in isometric games. Thank you so much!

  • Sorting Player vs enemy, npc or other simple objects would be simpler. You’d just compare the y positions.

    This'll get interesting once I apply this technique to sort NPCs near complex objects such as these, or on very thin, long, tall diagonal walls, with characters on both sides. (I'm guessing "Z Order Sort" is the optimal sorting method, but in my experience it overrides all other sorting and layering data/actions)

    I'll necro this thread next week with my results.

  • I think this line idea would work as long as the base of the wall is some kind of convex polygon. Bear in mind it’s counting on all the walls being sorted correctly as the only things that will be changing zorder are the moving objects represented by points.

    “Z order sort” is more for sorting everting. Let’s call it an absolute sort.

    Here we are doing a relative sort.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)