Event-based movements & collisions

0 favourites
  • 11 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • Practically every CC/C2 user, including myself, has relied on the built-in behaviors for movements & collisions. Because of this (and delta time making your own collisions difficult) there are no examples or anything on how to create your own movements & collisions with events or even the custom movement behavior. The built-in behaviors are pretty good but they don't cover everything...

    Anyway, what I'm trying to make is a "classic action/RPG" movement like those in Zelda:ALttP, Illusion of Gaia, Chrono Trigger, etc. In these games you can:

    -Move in 8 directions at a set speed (no acc/dec)

    -Move along diagonal walls (example)

    -Move up horizontal stairs (example)

    Does anyone know how this can be done?

  • Make some diagonal collision and you'll slide across/up it like that. If you want no acc/dec then set them to 0 in the behaviour properties.

  • The 8 directional behavior is pretty far off. It does not move against diagonal walls at all, and moves slower in ordinal directions than it does in cardinal directions. Also setting its acc/dec to 0 means it won't move at all..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah I guess I was imagining platform behaviour. That moves well against angles. If you set the deceleration higher than acc it doesn't tend to gradually slow down, which I guess is what you were trying to achieve?

  • I would recommend adding the keyboard from the input plugins. you can find it by clicking insert new object, then scroll down to input and there you'll see the keyboard, click on this to add it into your project, then go into your event sheet or create a character control event sheet, It's very useful when adding lots of animation for your sprite. you can use this to assign custom key controls, for movement angle/stepping speed and even configure the animation to be played or frame to be displayed when a key is down. as for acceleration / deceleration, try setting them to low and see how it goes, I'm no expert on construct I'm learning too. I'm currently working on my first platform, solving problems as I go.

    Hope this helps <img src="smileys/smiley4.gif" border="0" align="middle" />

  • *scratches head* I've been using CC/C2 for over 4 years man. I know lol. I'm just tired of relying on built-in behaviors and would like to start writing my own as I did in MMF and GM, but since CC/C2 use delta time it's not as easy and there isn't a single example on how to write your own collisions that aren't complete trash.

  • Have you tried a combination of 'move at angle' and 'push out solid'? I think there are quite a few options for the direction pushing out and it works smoothly, so you may be able to achieve your desired result.

    I am also interested in this, so let me know if you find anything. I'll have a try myself later too.

  • If deltatime is holding you back then ignore it and do your motion without it and deltatime can be added later.

    Anyway 8direction is simple enough to make with events. The main thing that's tricky is collision response or with those videos wall sliding. Here is a capx with the preliminaries of collision response.


    It's incomplete as I ran out of time today. If you remove event 14 then it should basically work like the behavior. On a side note you can get motion with the behavior without acceleration or deceleration by setting them very high.

    Anyway since you can't access the collision polygon from events you'll have to either make assumptions about the wall shape or devise a way to find approximately where the collision occurred and the angle of the side hit. One documented method floating around the internet is the separating axis theorem (or SAT). The only drawback is it's a bit lengthy and tedious to make with just events, although as a plugin it could be useful.

    I'll try to finish the example up over the next few days.

  • Here's an updated capx:


    It will work with arbitrary collision polygons but the wall sliding works best when the edges are in increments of 45 degrees. I found I didn't need that complicated vector math so all the formulas are fairly simple.

  • R0J0hound Thanks man, this is pretty solid! Kind of confused by the collideCheck function though - I didn't know you could use them that way. Also what is the purpose of events 11 & 12? Removing them doesn't seem to change anything.

  • I used the collideCheck function instead of using the events directly because I just wanted to know if the player is colliding, I don't want to pick the walls. The only reason for that was the nested overlap check in event 12; it needed to check with all the walls not just picked ones. Event 10 moves the player to the position it was at at the start of the frame, then events 11 and 12 move the player again but only a pixel at a time in the same direction. This is to close the gap with the wall. The player's d variable is reduced by the amount moved. This is important so the wall sliding can only go the remaining distance.

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