How do I spawn enemy and make them move smartly?

0 favourites
  • 3 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Hello.

    I am completely new (still).

    I have been accepted into a game making incubator workshop but had to be absent for the major part due to my mom passing way of cancer. Now the deadline is approaching and I am trying to figure out a lot of things on my own, which is really scary as I am making this game for her.

    Anyways some background info as to why I need such quick, last minute infos...

    SO I made a platformer game, a simple game where the character has to kill as many enemies and "knock" over garbage cans to find a "time extender" to continue.

    Anyways, I set up the game, have my character set up as some tutorial on this site (player box with player). My character has the platformer behaviour.

    I have one enemy sprite that has also the platformer behaviour with simulated controls (+ on collision, destroy),, except my enemies won't move... or spawn.

    What I need is the enemy to be spawned regularly on the ground level (every 3 seconds approx) and to move towards the player and jump if needed on top of invisible solids and sort of "follow". If that's too complex, it's fine to tell me it is and I can do a simpler mechanic.

    Also, need to make sure that once there is more than 5 enemies on the layout, to temporarily stop enemy spawning production until the number of enemy goes down to less than 5.

    Once a certain amount of enemy is destroyed, I want to spawn a BOSS enemy.

    That's the gist of it but as I am new... and because I am struggling with all of the above, it's a bit difficult to figure it out on my own despite having done 5-6 tutorials.

    I will have many other questions on this. If you feel especially kind, please feel free to lend me a helping hand.

  • I'm sorry to hear about your mom. While I was writing this, the song "Only love can hurt like this" was playing in the background, and I think that means something.

    For your game, this seems doable.

    To spawn enemies, first make a spawner object. This can just be a rectangle with initial visibility false. Give it an instance variable, like "to spawn," and set it to the most enemies you want on screen

    For the conditions, use System: Every X seconds AND Spawner object: compare value: "to spawn" > 0

    For the actions, use spawner object: spawn another object: enemy AND spawner object: subtract from: 1 from "to spawn"

    To add back in to the counter, use

    enemy: on destroyed

    spawner: add to : 1 to "to spawn"

    Note: this assumes you're using only 1 spawner.

    For enemy movement, I just use

    enemy: compare x: > player.x

    enemy:simulate control: right


    enemy: simulate control: left

    To jump, you could try

    enemy: is moving, invert condition (right click the condition and select "invert")

    enemy: simulate control: jump

    As far as making the boss, you would probably need a global variable like "points."

    Add the action "system: add to: 1 to points" to the enemy destroyed event

    Add the condition "system: compare value: points < (the number of enemies you want killed before the boss spawns)" to the spawning event.

    Add the new event:

    System: compare value: points >= (number to spawn boss)

    Spawner: spawn another object: boss

    And give the boss the AI you want, maybe the same as the base enemies.

  • Try Construct 3

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

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

    Caleb Bennetts, thanks for your reply.

    Indeed, that song is quite accurate.

    I have set up the conditions but it does not seem to work on my test run. Do you mind taking a look at the print screen of my game? I'll try and post the screen asap

    Thank you again

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