Enemy Spawning

This forum is currently in read-only mode.
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • I'm creating a game and I've run into a problem. In my game, there is supposed to be a maximum of five enemies all at once. However, that is not the case. I have the computer spawn a sprite that is either an enemy pistol-man or an enemy shotgun determined by a random (1 or 2) global variable. Then, depending on which number is chosen, the computer spawns the enemy sprite when one sprite is killed. The problem is that the computer will actually spawn more than one sprite(I think, either that or randomly creating sprites which it shouldn't since I have it set up as a condition connected to another condition). Any ideas on why this is happening? Thanks in advance.

    P.S. Not sure how to post a .cap. Will do so if told how to. Thanks

    Edit: Here's the cap


    It's only my second game, so the events are a little all over the place.

    Edit 2: Just remembered that I don't mention the controls in the game. They are:


    Left Click- shoot

    Right Click- run

    Control- switch weapon

  • Sounds like a simple mistake in your events. You can upload a .cap to a site like box.net and post the link here.

  • Hi. There is a simple error in your testing of the global variable:

    + orange_pistol_enemy2: Value 'Hit Count' Less or equal 0

    -> orange_pistol_enemy2: Destroy

    -> System: Set global variable 'enemy_choice' to random(2)

    -> player: Add 1 to 'Score'


    + System: global('enemy_choice') Equal to 1

    -> System: Create object orange_pistol_enemy2 on layer 1 at (random(3000), random(3000))

    + System: global('enemy_choice') Lower or equal 1

    -> System: Create object green_shotgun_enemy on layer 1 at (random (3000), random(3000))

    -> green_shotgun_enemy: Set speed to 200

    Random(2) will result in either zero or one. If it's zero, you'll get a shotgun enemy. if it's one, you'll get both enemies, because both are true on one.

    So, Lower or equal 1 should be Equal to 0, or possibly Lower than 1. In this case, I'd favor direct equality testing with Equal to 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Mr. Wolf and Silent Cacophony. I learned two new things today.

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