Spawning Enemy Problem?!?!?

0 favourites
  • 13 posts
From the Asset Store
For problem solving, puzzles, bubbles, platforms and other adventures.
  • Okay my game consists of an enemy that can spawn in 1 of 2 places. I did this by copy and pasting the enemy and then using the 'pick random instance' and then create enemy. (they spawn every 2 seconds)

    When running it through my browser it works fine and it chooses one of the to spawning positions as I wanted. I have created a front page for the game which is basically an image and the play button which will take you to the game layout, which again when running through my browser works fine. However...........................when I run it through my browser just for the very start of the game it will spawn 2 enemies either overlapping on another or from both spawn positions together.

    I can only assume that when I run it through my browser, when I'm on the start layout and not the game layout if I wait 2 seconds or more then the game layout is already running and therefore will spawn an enemy (since it spawns every 2 seconds) which will accompany the other enemy.

    I thought that I should then have that 'on start of layout'............and then input the **'pick random instance' and then create enemy**. This still didn't work.

    Does anyone know what I'm doing wrong?

    THANK YOU SO MUCH!!!!!!!!!!!!!!!!!!!!

  • yes the Every 2 seconds event starts immediately after the layout is loaded.

    Make sure you are destroying the object On Start of Layout since in the editor you may have it on the screen.

  • But when i code 'on start of layout - destroy enemy' the enemy doesn't spawn at all after that since its just been destroyed

  • does your spawn condition require there to be an enemy somewhere?

    I'd need to see your capx

  • Yeah here is a screenshot.............

  • Hi,

    Delete "pick a random..... instance", it should work

  • Won't that cause both enemies to spawn at the same time?

  • Im pretty sure it wont work, if you have "Pick a random Ninjaspawnplace" and there are none in the layout, then that will turn False and it will never create any new ninjasspawnplace for you.

    It seems a bit weird why you would pick a random Spawn place and then create another spawn place? From your original description, it sounded like you wanted to spawn enemies at the spawn locations and not new spawn places? but maybe I misunderstood that.

  • if all the instance are destroyed , the system can not pick one random

  • I'll create a quick image now of what I mean.

  • But in the screenshot in the other post where you spawn every 2 seconds. You are spawning NinjaSpawnSpikes is that correct? because it seems wrong why you would select a random NinjaSpawnSpikes and then spawn the same object from it, based on the description and the image you provided. If NinjaSpawnSpikes are your enemies, you have to pick one of the spawn places in that event right? otherwise if the NinjaSpawnSpikes are your spawning place, shouldn't you create enemies in that event rather than more NinjaSpawnSpikes, it just seems like there is something wrong.

    Or in another way.

    What is the name of your Spawn area? and what are the enemies name? (In C2 under name tab)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • nimos100 You were right! I managed to sort it out thank you

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