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

Get help using Construct 2

Post » Mon Aug 15, 2016 8:49 pm

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.

ImageImage

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.

Image
Image

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!
B
30
S
15
G
22
Posts: 183
Reputation: 14,221

Post » Mon Aug 15, 2016 11:10 pm

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.
B
52
S
24
G
18
Posts: 295
Reputation: 13,090

Post » Tue Aug 16, 2016 6:56 am

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 ;)
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Tue Aug 16, 2016 10:40 pm

@Supwiththat? 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.

Image
Image

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!
B
30
S
15
G
22
Posts: 183
Reputation: 14,221

Post » Wed Aug 17, 2016 8:04 am

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.
B
52
S
24
G
18
Posts: 295
Reputation: 13,090


Return to How do I....?

Who is online

Users browsing this forum: koops and 8 guests