Set to "harmless" on spawn

0 favourites
  • 6 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • <font face="Arial, Helvetica, sans-serif">

    So, basically I got a caged survival game where enemies spawn every set seconds and the player's task is to just dodge them.

    Enemies are homing to player's direction and set into bullet. Spawn are set into random to the coordinates of the playing field/layout.

    Now I want to make the enemies "harmless" on spawn where it:

    1. Set a flash effect/animation to indicate that it is spawning

    2. Stop moving on spawn for the whole duration of the animation (around a sec or so)

    3. Set into "harmful" after the animations and start chasing the player to death again <img src="smileys/smiley1.gif" border="0" align="middle" />

    This serves as a warning system so that the player doesn't die from frustration due to the occasional "enemy spawn on player". Tried a whole lot of things and it just didn't work, so any kind of help is highly appreciated.

    Thanks before. </font> <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Add the flash behaviour to the enemies, then in the events - on flash finished set harmful to TRUE and only chase player when it's TRUE of course.

    An easier option might be to place a few spawn points around the level, and maybe pick the furthest one away from the player and spawn there.

    Another method would be to check the coords of the spawn, if it's less than a certain distance from the player, then try different coords until they're far enough from the player, then spawn.

    Sorry, slight hangover so not really sure if that makes sense, although it does to me ;p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Did your advice and it went great. Thanks a lot. Now enemies spawned motionless and move only after the flash ended.

    Now the only thing I still need to solve is that I want the player to be able to "pass through" (no collision) the enemies when it still do that flashing animation.

    Any recommendation on how to solve this problem?

    Again, thanks before :D

  • I thought I might not have explained things properly, but great to hear it worked!

    Just add these new sub events to your collision code..

    + On collision / overlap whatever

    + Pick closest enemy to player << may not be needed, depends on your checking

    + If harmful is TRUE << new sub event

    • Do collision stuff

    This way, it'll only execute the collision events if harmful is TRUE, otherwise it'll just skip it.

    Make sense?

  • wow, can't believe it's that simple. It works perfectly now, just like how I wanted it. Thanks a lot!

  • Yes, it's always the obvious things you don't think about. I get that a lot believe it or not ;p

    Glad I could help. Just shout if you have any more problems.

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