How do I make my enemy jump [Platformer]

0 favourites
  • 15 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • Hi everyone,

    I've been watching and reading many tutorials, but after hours of looking, I haven't found the answer to this (even though I learned some other cool things).

    I am trying to to make a platformer/shooter game where one of the enemies chases you around to hit you. I want my enemy to be able to chase you even by jumping to another platform. So far I've only been able to make him float and chase me around using Line Of Sight, but I can't make him land bound.

    Any advice on this? Thanks in advance.

    "Enemy" has Line of Sight, Bullet, and Bound to Layout for Behavior.

  • If you put platform behavior for the enemy, Set Default Controls to No and Use Simulate Jump action.

    As for the condition when to jump, use invisible sensors (check if enemy overlaps sensor), then enemy jumps.

    Adjust Enemy's platform parameter Jump Strength to your preference.

    ktb

  • sgn15

    It...Sort of worked. My enemies chase me bouncing (I assume because they're following PlayerBox.X and since the box is smaller, they're looking down while walking. I'm not sure about this.

    What do you mean by invisible sensors? I'm afraid I haven't learned that one yet.

    I tried making it so that a condition (PlayerBox.Y) is higher than Enemy.Y would trigger them to jump every 2 seconds, but they would just continue doing that regardless, because PB's Y was always Higher.

    I'm kinda lost right now.

  • Any object that is set to invisible during the game itself and its only purpose is to act as enemy's sensor/detector (which is done by overlapping)

    I'm not sure which is your player in the pic and which is your enemy and what is that circle with an L in it, but I don't think you need to check your X and Y for enemy to jump. Just check if enemy overlaps the sensors (which you should put in the layout before runtime) then simulate jump.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sgn15

    I guess I'll place sensors on top of the platforms and I'll let you know.

    For now the green squares is my player and the red the enemy. The L icon is a placeholder for ammo pickup.

    Do you have any advice on how to make the enemy square move forward like my player? Right now when it moves forward it sort of tilts forward.

    In any ways, thank you very much for answering, and I'll keep you posted on how it goes

  • Still not sure about the overall theme of your game, is that thin line a platform (jump thru or solid) ?

    If it's a horizontal layout and you keep on running and enemies chase you, place thin vertical line sensors on each area where enemy needs to jump

    Use Vector X to make any object with platform behavior to move horizontally, Vector Y to make it move vertically. You can use vector X while jumping

  • sgn15

    Yes, that thin line is a platform, jump-thru. I wonder if that's why when I jump on it I stay and the others fall through it.

    I understand sensors, but why vertical instead of horizontal?

  • If player and enemies are running horizontally, then you pass through the vertical sensors. I mean "vertical" as a thin long vertical line (shape of sensor).

    Not sure if we are misunderstanding each other.

  • See if the attached capx helps. It's not 100% what your asking for but it get's the enemy chasing the player when in sight, and the enemy will jump onto platforms if the player Y position is less than the enemy Y position, the player is not falling, and the enemy hits the sensor (called jumpbox in the capx).

    And there's no angle changes in the enemy.

    I'm sure there's better ways to do this, but hopefully it will help.

  • nickl this was EXACTLY what I needed.

    It took me some time to understand the events, but I get it now. Thank you guys, I'm making progress

    Please let me know if I can help you with anything (testing, etc).

  • nickl

    Why do we need a to create a global variable for the enemy's speed?

    I thought variables' names had no value - does adding "speed" refer to the set speed of the object? (in this case the enemy's)

  • PixelBoss

    That global variable is not strictly necessary. In events 1 and 3 we check to see if the enemy has line of site to the player, if it does we tell the enemy to move towards the player at EnemySpeed. Having the EnemySpeed variable means we can just change the EnemySpeed from 3 to 2 to make the enemy move slower, or change it to 4 to make the enemy move quicker.

    We could remove EnemySpeed and hard code the speed values in events 1 and 3 instead if we wanted.

    Also, calling the variable EnemySpeed is just a name, we could of called it anything, it's just used to set the rate at which we move the Enemy along the X axis.

    Double click the EnemySpeed variable, change it's name to anything and C2 will update the events that used EnemySpeed with the new name.

  • nickl I understand now so they work like gears in a car. I had not thought about implementing different speeds, so that's why I didn't understand.

    Once again, thank you very much for teaching me. I think after a few mour hours spent on C2 I may end up buying it - the 4 layer limit really rustled my jimmies.

  • Your welcome.

    If your thinking of purchasing C2 I really can't recommend it enough. I've tried GMS, AGK2, Unity, Phaser.io and probably more, but C2 is the one I use. However, as with most things, it's not the tool it's how you use it .. and how much FUN you get from using it

  • nickl

    Wow, I really appreciate that last comment, because I've been thinking about other softwares too.

    Thank you so much for your mini lessons and feedback. You've won a cyber-beer as a token of my appreciation (granted that you're of legal age and like beer, otherwise please accept an e-cookie).

    Please do let me know if I can do anything for you, like testing a game.

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