lukezero's Recent Forum Activity

  • Hi pals!

    I'm developing a 2D platform game and I want to establish a good and challenging AI. I've been using "Compare X" to implement basic AI behaviors in enemies, but I'm having difficulty because C2's Line of Sight is very flawed.

    I thank you in advance for your attention and collaboration!

  • You do not have permission to view this post

  • Here you have it: fileport.io/3eErBLhXX4zW

    Thank you very much! :D

  • Hi guys!

    I spent a lot of time here trying to make a good amount of fireflies with a similar behavior to the animated GIF below using particles, but I didn't get anything close to that.

    Do you have any suggestions? Examples in CAPX?

    Thanks in advance!

  • Hi guys!

    I spent a lot of time here trying to make a good amount of fireflies with a similar behavior to the animated GIF below using particles, but I didn't get anything close to that.

    Do you have any suggestions? Examples in CAPX?

    Thanks in advance!

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Supposing that you have an "HUD" layer with parallax 0% where you want to position your coins after you collect them; the problem is that in your code you keep your coin in the same layer and you treat the hud coordinates the same way as the world coordinates.

    What i mean is that you may have your coin at position x:2000, y:2000 in your game world. If you simply move it to x:50 y:50, you're still moving the coin in the game world.

    So, what you need to do is move the coin to the HUD layer and set its position to the position the coin would have if it was on that layer to begin with. Basically you need to translate the coin coordinates from the "Game" layer to the "HUD" layer.

    Here's a revised version of the code:

    Note that Construct has specific expressions to make the translation easier:

    CanvasToLayerX(layer, x, y)

    CanvasToLayerY(layer, x, y)

    LayerToCanvasX(layer, x, y)

    LayerToCanvasY(layer, x, y)

    Thanks a lot, dude! It worked very well! :D

  • Hi guys!

    I'm developing a platform game where collectible coins automatically go to the HUD in the top left of the screen when the character collects them in the stages, as in the image below:

    Since I couldn't do it using the bullet and Line of Sight behavior (!!!), I resorted to Lerp and/or Position to do it successfully.

    However, since the game's coins and the HUD are on different layers, the last coins collected are always shifted several pixels forward when they are collected, causing a strange effect.

    I tried to solve it using Viewport expressions and creating two variables (TargetX and TargetY), but I was unsuccessful (see image below).

    Does anyone have any suggestions on how to solve this in C2?

    Thank you in advance!

    Tagged:

  • You do not have permission to view this post

  • 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

  • You do not have permission to view this post

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

lukezero's avatar

lukezero

Member since 4 Oct, 2014

None one is following lukezero yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies