How do I respawn mobs room to room like Mega Man or Metroid?

0 favourites
  • 5 posts
From the Asset Store
Huge collection of explosive devices and explosion effects
  • Hey all. I'm trying to create this sort of "feature" or effect in my prototype. Found in games like Metroid, Mega Man and Castlevania.

    Here's my attempt. The whole layout is made out of zones. I have 2 robots in that specific zone or "room" in the editor. I can't seem to have the bots be destroyed or "inactive" when the player is not in that room. When I enter that room though, I spawn 2 more bots into the room.

    I've found this topic being tackled by other users but I don't understand all the concepts. How do I like the link a group of enemies to the specific zone/room they're in? With a family or a container? Any tips on how to recreate this feature would be appreciated. Thanks!

  • If you're using some hidden object to control the scrolling of the screen, maybe you can link the bot spawns to the proximity of the object. Sort of like,

    If Bot is not within [Viewport distance] of Scroll Thing --> Destroy Bot

    If Spawn Point is within [Viewport distance] of Scroll Thing --> Spawn bots/Recreate bots

    This way the bots would be destroyed when the object pans away to another zone, and spawned and/or recreated when it come back.

  • In short, surround each room with a "zone" using a sprite or 9-patch. If the player enters a new zone, destroy the enemies/objects outside of its bounding box and use 'recreate initial objects' inside of its bounding box. To be extra safe you can destroy objects outside of the previous room first, then recreate the new room, then destroy everything outside of the new room. Depends on the type of transition you want, really.

    Not to shamelessly advertise, but my Metroidvania Game Kit does exactly this

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ? The camera scrolls with the player but camera is locked into zones and the zones vary in size. Do you mean using a LOS behavior on enemies to detect if they're near the player?

    Tokinsom Hey, thanks a lot for the help! Seems to be working correctly now! The way I have it set up is, when you enter a certain room, it destroy the enemies in the adjacent rooms and spawns enemies in the current room. I grouped the robot enemies in the room as their own family.

    I'm a little confused about the nature of families though. Do I have to make a family for the groups of enemies that are in each zone so they spawn and destroy correctly? Or would just using the family marked as "Enemies" (that have all the enemy sprites within) suffice? Because I'm using both and they both seem to work. The very fast worm-looking creatures are in the overall "Enemies" family that includes most enemies sprites. I'm just trying to come up with the most code efficient way to do this since Metroidvania's can become rather large.

    Tokinsom I've definitely considered picking up your game kit The way I look at it though is that I'll never truly learn C2 if I just use someone's template. Building this prototype has been an awesome learning experience and I'm a lot more confident with C2 than I was 6 months ago!

  • I was thinking a simple proximity check like "Bot distance to player greater than X --> destroy Bot", in which X can correspond roughly to the size of the viewport so that when the camera gets closer/further they're spawned or destroyed. Might not work as well if zones vary in size though, because if a zone is several screen lengths across a bot on one end would not spawn until the player moved closer, despite being in the same zone.

    LOS can be a way to do it as well I guess, just separate the zones with objects designated as LOS obstacles. That way bots in one zone won't be able to see the player when he's in another zone.

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