Platform Collision Check w/out Using Solid Behavior

0 favourites
  • 13 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • I'm working on a game where you can switch between the foreground and background to avoid detection by guards. Doing this also allows the player to go behind or in front of solid objects (ie: a stack of boxes in the background can be passed in the front).

    Regarding just the player, this is not an issue.

    In order to avoid stopping the player from walking passed the boxes (or other objects that would normally have the Solid behavior), I can simply test if the player is on the same layer as the boxes. If not, I turn off the Solid behavior and the boxes are nothing more than sprites.

    The problem is when I include the enemies who also will use the Platform behavior and will need to be able to interact with objects that are supposed to be solid (regardless of the layer the player is on). Because if the payer is on a different layer than the solid object, then I'd have to turn off the Solid behavior. But if an enemy is on top of those solid objects, they'll fall through the sprites due to their Platform behavior...no Solid to hold them up.

    So I need to work out a different system of collision detection AND, more importantly, how to make "solid" objects act like solid objects without the solid behavior.

    So far, I have figured out, for example, how to use Overlap or Overlap At Offset to place the player on top of the boxes when he jumps up and falls to land on top of them. Problem is, if I walk up to the boxes from the side, the conditions still puts the player on top of the box. Part of that, I'm sure, just requires a couple extra conditions to test for the X position as well as the Y position of the player.

    Still, even with that understanding, I'm struggling to find the best way to test for these conditions in the same vein that the Solid + Platform behaviors do. May I get some input on this, please?

  • You're entering the 3rd dimension *creepy sound*

    That is a bunch of work with Construct 2(D).

    You should change to a 3D engine. Thet will do this work for you.

    http://www.gamestudio.de/ is an easy to learn 3D studio and it's able to do 2D projections.

  • Not really the answer I'm looking for.

    I don't have time to learn a new game editor...

  • Read between the lines.

    There is no 'easy' solution for this.

    C2 only has solid behavior (for all platform objects).

    You want to have a layered platform behavior but also with joined layers at some circumstances.

    This is not possible with C2, except rewriting the C2 platform behavior for your needs.

    My advice: leave it or change to an engine build for.

  • I realize it's not easy. That's why I'm asking for help.

    I know there is a solution - I can almost see it in my head. I just need help sorting out the details.

    I already figured out part of it but I can see there's still more to account for. It can be done.

    Already someone on one of the FB C2 groups suggested a workaround that doesn't involve using the Platform behavior for the enemies. So while more work, it potentially can solve my problem.

    So, while I appreciate your advice, as I said, it's not the answer I'm looking for.

  • Sounds like you just want to deal with calculating collisions yourself. If that's the case, you could probably just search online for general info on how to do this since a lot of developers handle it themselves in other engines, programming languages, etc.

    I haven't done this sort of thing in a long while so I've forgotten a lot. I think you just need to start anywhere and keep digging into it since there is a lot of material online..

    here's what a quick search found me: http://noonat.github.io/intersect/

    If you do figure out how to do it, I'd be interested too.

  • ..there's also this page that I have bookmarked, which has a lot of useful information:

    http://www.metanetsoftware.com/technique/tutorialA.html

  • (Disclaimer: Havent tried this myself)

    When you move to other layer, try setting the Player's Collision property to false. If Solid Object.Layer = Player.Layer then set the collision back to true.

    Not sure if it will help you, but its worth a try. Note that Player will not collide with any object when Collision is off.

    Edit: Have a transparent sprite pinned around the player, whose collision is always ON, but its not solid. When it collides with a Solid Obstacle and Solid Object.Layer != Player.Layer , then set collision to OFF/False

  • Thank you, both. I'll look up those links.

    The main issue with disabling collisions is that I still need a collision detection of sorts, regardless of which layer the player is on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • another option might be to copy the solid behavior files into a new behavior and modify them so that it works in the way you need it to- assuming it can be modified to work the way you need it to

  • (Disclaimer: Havent tried this myself)

    When you move to other layer, try setting the Player's Collision property to false. If Solid Object.Layer = Player.Layer then set the collision back to true.

    Not sure if it will help you, but its worth a try. Note that Player will not collide with any object when Collision is off.

    Edit: Have a transparent sprite pinned around the player, whose collision is always ON, but its not solid. When it collides with a Solid Obstacle and Solid Object.Layer != Player.Layer , then set collision to OFF/False

  • BTW, could you paste a screenshot of your game? I am suspecting you are developing a isometric kind of game and need player to be able to walk infront of an object.

    If so, dont mark the entire Sprite with Collision polygon, just make the base of the sprite solid.

    See the trees on this screenshot. Instead of marking the entire tree as Solid, only the base of the tree is marked as Solid. In C2, you use the Collision polygon to mark its solid area.

    Once you have done this, you dont need different layers anymore (of course floor will still be a different layer),

    Just check the Y position of the each colliding objects, which ever has a greater Y value comes to Top of layer ("Move to Top of Layer" action)

  • That's basically just manually doing the platform behavior, since it's the platform behavior that makes the objects act solid.

    Basically once the object overlaps a wall, you'd move it out in some direction till it's not overlapping. If the object isn't overlapping at its old position then move toward there. The other case is if you just place the Sprite in the wall, and it should just be moved to the closest open space.

    That's only the first part. After that try moving horizontally then vertically to get to the place it was overlapping. Of course just stopping short. When moving horizontally and it hits a solid then set the horizontal speed to zero. The same for vertical. Without this part the object would just stick to walls. When moving vertically you can find when the Sprite is on the ground, and there is where you'd simulate a jump if the jump key is pressed.

    Slopes would need some extra logic when moving horizontally, and moving platforms would need some logic too. It just depends what you need.

    Also here's an entirely different idea I posted elsewhere before. It still uses solid but makes a duplicate of the layout in a different location.

    https://www.dropbox.com/s/i1vr8srq201gw ... .capx?dl=0

    Here's the topic it's from. Maybe one of those solutions will help.

    ignore-selected-solids-workaround-list_t167029?&hilit=Disable+collision

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