Custom collision

This forum is currently in read-only mode.
From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • I am trying to put together the basics of a roguelike. I wanted to use the keypad for movement so I set up custom tile movement using that system. What I am trying to do now is create tiles that block movement. The problem I'm having is that the solid system only works with specific movement behaviors.

    I can't use 8-direction movement b/c it doesn't seem to function on a grid. I tried the grid movement behavior but it's only 4 directions. The grid behavior has the stop function I'm looking for, though. If I add that behavior to my player, mark them solid and then mark my impassable tiles solid, the player is stopped immediately.

    For my custom movement, however, that doesn't work. I've tried doing things with collision events, but there doesn't seem to be a basic 'block movement' action. Using bounce causes extra movement when pressing into the blocking tiles. When a player pushes toward a blocking tile I just want them to stop. Would I have to do this by adding conditionals to all my custom movement code?

  • I would do better with a little example cap, but what came to my mind first was OVERLAP AT OFFSET... Did you try that? Search for the "Is overlapping at offset" condition.

  • you should play around and get to know construct and the event system better. Try what pixelrebirth suggested, it will work. Platform school might help if you haven't tried it.

  • I tried the overlapping at offset. There are two issues:

    1) It only takes an x and y, which means any effects won't be applied when you move on a diagonal.

    2) There's no basic 'stop movement' effect - bounce causes random movement off the grid, I tried a few others like 'push out' and moving along the opposite angle but none of them just prevented movement

    I'm guessing the solid effect is something that's hard-coded in and only works with the built-in movement behaviors?

    Also, thanks for the suggestion, but I went through the tutorials already. The platform school didn't help b/c I don't need any of the platform behavior (the game is top-down). It does seem that maybe the solids behavior is something that's just hard-coded - it would be nice if you could tag something as a physics object and then solid and have the basic collision work right off the bat.

    It may just be easier to work on a platform game, at least until I can work out some Python coding.

  • I tried the overlapping at offset. There are two issues:

    1) It only takes an x and y, which means any effects won't be applied when you move on a diagonal.

    I don't really get what you mean by that. By using the right coordinates for your offset, you can check for diagonal units without a problem.

    2) There's no basic 'stop movement' effect - bounce causes random movement off the grid, I tried a few others like 'push out' and moving along the opposite angle but none of them just prevented movement

    Make your stop action with events. Check for the offset overlap in the direction the player is about to move and only move it, if it doesn't overlap solid.

    I think I'll post a cap later which demonstrates the use of the mentioned method more clearly to you. I'm just not at the right computer atm. I remember there was a very basic example when overlap at offset was first introduced by one of the devs. But I'm afraid I can't find it with the forum search (since it sucks ).

  • I think I get what you're saying. Basically, do conditional checks for collision before I allow any movement. Something like:

    IF button numpad 2 is pressed -

    IF overlapping at offset x,y with object z, then do nothing

    ELSE move 32 px at 90 degrees

    That's a really good idea. What I was trying to do was separate those checks out. It may be tough to conditionalize all my movement code but I may be able to set up some kind of python switch script that will add all that stuff together in a simpler manner.

    I'll have to figure out exactly what I need to put in for the diagonal checking (if the x,y checks go off the objects borders then there will always be gaps in the diagonals - that's another matter, though, and one I'll take a look at).

    Thanks for the help.

  • Okay I looked a little into this and made the following:

    Something Roguelikeish

    I hope this is somewhere near what you had in mind. I'm using the ball behavior, some private variables and, of course, some events. I didn't have the patience to comment the events though so far. Let me know if you could use a commented version and I will make that happen.

    Also note that there's a deactivated event group, which features a simpler moving method. It jumps directly to the next field instead of moving there.

    EDIT: It is indeed the case that this could be so much easier if the Grid behavior supported 8 directions/diagonal movement. Feature request? Or is it already requested?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see what you did. I'll have to definitely look at the code in more detail. Looks very similar to what I thought would have to be done.

    The funny thing is that you're basically simulating 4-direction movement and adding diagonal support. Very clever. Lots of conditionals, but it gets the job done.

    It would be great if I could use the platform behavior to set the gravity to the z-direction. Then I could just stepwise all movement, which would probably help once I go about working out how to do the turns.

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