lukezero's Forum Posts

  • For tiles platforms, you can simply use the Tilemap expressions to detect if the enemy has reached the end of any platform. And, for sprites platforms, you can easily compare the coordinates of the enemy and the platform, this will work even with mobile platforms.

    Check this: fileport.io/tyaTYhsxL2Ae

    Thanks again, dude!

    You did too much here!

  • Lionz’ suggestion is by far the easiest. Just put invisible sprites on the edges of the platforms, and have the enemy change direction when colliding with them.

    If it’s too laborious to place the sprites then there is likely a way to automate placing them, but it depends how you make your platforms.

    Another way could be to detect the edges of the platform with a small detector sprite. Say the enemy is moving right. Move the detector sprite to the bottom right corner of the enemy. If the detector isn’t overlapping a platform the change the enemy direction to left. You’d do similar logic for moving left. You could also use “pick overlapping point” instead of a small detector sprite.

    A third way could be just to pick the platform the enemy is on and change direction when getting close to the edge. Would work well if the platform is just one long object. Logic for the right edge would be the following. Left edge is similar.

    For each enemy

    Enemy overlaps platform at offset(0,1)

    Enemy: is moving right

    Compare: enemy.bboxright>platform.bboxright

    — enemy: set direction to left

    Fourth way would be to just use the sine behavior to move the enemy. Place the enemy at the center of the platform, set the magnitude to half the platform width, set motion to horizontal and wave to triangle. I’m unsure if position would drift over time though with different frame rates.

    There are probably many other possible solutions.

    Thanks, Rojo! I'll test your suggestions later.

    You´re always saving the day! :D

  • Hi guys!

    Does anyone have a C2 project file for a basic routine for the patrol enemy behavior of a typical platform game?

    The kind that walks around autonomously, always turning back when it comes across the edge of a platform.

    Thank you for your attention and collaboration as always!

  • Remember: I still using C2, guys. ^^

  • > > Detect "holes" in the floor with a raycast.

    > > wackytoaster.at/parachute/enemyturnaround.c3p

    >

    > Construct 2 doesn't have these Line of Sight parameters. :(

    >

    > Do you know what the alternative would be in C2 to replace them?

    You can sort of replace raycasts with sprites and just check "is overlapping ground"

    Okay, but how do I do that? :)

  • Check it: fileport.io/pMSy9NrXcaqm

    Thanks! But what about using Sprites as platforms?

  • The platforms in your game, are they tiles? Or are they sprites?

    I use both, but most of the enemies are on sprite platforms.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Detect "holes" in the floor with a raycast.

    https://wackytoaster.at/parachute/enemyturnaround.c3p

    Construct 2 doesn't have these Line of Sight parameters. :(

    Do you know what the alternative would be in C2 to replace them?

  • Detect "holes" in the floor with a raycast.

    https://wackytoaster.at/parachute/enemyturnaround.c3p

    Thank you very much! :D

  • I kindly ask again: does anyone here have a short example, CAPX or C3, of a basic functional behavior of an enemy with patrol behavior for a 2D platform game?

    I really need it urgently, amidst a thousand demands for an educational game with a very small team. :(

  • Do you mean a patrolling enemy that changes direction when it reaches the platform edge? You can put invisible sprites at the end of the platform, when it touches one of them toggle a boolean that relates to simulating left/right on the enemy platform behaviour.

    I would like a solution that does not require a physical barrier, that works in a more universal and adaptable way. There will not always be a wall in front of the enemy. Sometimes there will be a precipice.

  • Take a look at the Kiwi Story game in the examples, it has an enemy with this patrolling behaviour.

    I don't have a C3 license, so I can't fully access the project. :(

  • Hi guys!

    Does anyone have a project file (C2/C3) for a basic routine for the patrol enemy behavior of a typical platform game?

    The kind that walks around autonomously, always turning back when it comes across the edge of a platform.

    Thank you for your attention and collaboration as always!

  • I don’t have an example. But since you only use C2 a non third party solution could be to load the image you want to sheer into the sprite’s animations as a sprite sheet. So say the image is 320x64 you’d import that image with spriteSheet import with 1,64. That would give you a bunch of 1 pixel tall strips of the image. Be sure to set the animation speed to 0. And probably set the origin to the top left.

    Next is to place it. It’s a pain to place 64 instances and set the frame of each one so you can do that with some events:

    Start of layout
    Repeat 64 times
    — create sprite at (0, 480-64+loopindex)
    — sprite: set animation frame to loopindex

    Then to sheer right you can do:

    Sprite: set x to self.x+lerp(10,100, self.iid/64)*dt

    Where 10 is the speed of the top row and 100 is the speed of the bottom. Tune the values to your liking. Moving left would just be subtracting.

    You can avoid the image slicing step by using a tiledbg. The con with that is there will be more overdraw and the sides of the sheer will look off

    Start of layout
    Repeat 64 times
    — create tiledbg at (0, 480-64)
    — tiledbg: set height to 64-loopindex

    And

    Tiledbg: set x to self.x+lerp(100,10, self.iid/64)*dt

    Notice the 10 and 100 are reversed.

    Beyond that you could use a third party plugin to do a sheer. Paster is one option with its draw textured quad action. You’d basically just select a sprite to get the texture, and set the four corner positions.

    Thanks a lot! You're the man! :D

  • You could also apply a sheer with mesh distort if you want to do it in the same way they did it in sf2. Basically make a 2x2 mesh and move the top two points left or right by the same amount.

    Thanks, dude!

    Do you have an example of this?

    I ask because I'm a designer, not a programmer. ^^