Enemy Stacks

0 favourites
From the Asset Store
Stacking tower is a game to try to make the tower higher
  • Hello,

    Right now, I'm trying to implement an enemy stack, where multiple enemies will be standing on top of each other to form a tower. I think lots of games do this, but for example one would be Mario Maker, where you can stack up a bunch of Goombas or other enemies.

    I've tried a few things, but they haven't really worked. If anyone has done something similar before or knows how to do it, I'd really appreciate your help!

    Thanks,

    Snalec

  • Link to an example?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://www.youtube.com/watch?v=VGKA3khdN7I&ab_channel=ericfortesTV

    Here you go. They don't really do it in this level, but Mario can throw a shell or projectile at a Goomba in the middle of the stack, which would cause the Goombas to fall onto the ones beneath it. For example, if there were five stacked on top of each other, and the middle one was destroyed, the top two would fall onto the bottom two. Hope that makes sense.

  • I've done a quick example using individual sprites. There are plenty of ways you could do this though, including using the new hierarchy tools.

    In the example you click on the goombas to destroy them, this could be substituted with whatever method of removing them from the game you choose.

    1drv.ms/u/s!AkmrWgxeuxlKhIcMiraEjTB8iJqfNg

  • Awesome! Thank you so much. I have a few questions about it.

    Does overlapping at offset just mean that, in checking that collision, it moves the collision ten pixels down?

    Also, with the formula at the end, I don't quite know all that's happening there but I think I get most of it. I'm guessing the 100 in there is the height of the Goomba. I'm not quite sure about the 10 though. Does that correlate to the 10 in the overlapping at offset condition?

    Here's that formula for reference: lerp(Self.Y,(Self.Ypos+100),dt*10)

    Thanks again!

  • No Worries.

    Yes the overlap at offset checks for an overlapping object at a specific distance. You could use any number within the size of the object to be checked here to find an overlap. Here I'm using it to check if a goomba is seeing another goomba or the ground directly beneath it.

    The goombas are 100x100px so that's why the formula has the current position of the goomba +100. On the Y axis, + is down with 0 being at the top of the screen.

    Lerp is a way of smoothly interpolating between two numbers at a given rate, so we are asking it to move from the current Y position of the object (self.Y) to a predefined position which is the original Y position of the object+100px on the Y axis (self.Ypos"instance variable"+100px), and we are asking it to do it at a rate of (dt*10). dt is Delta Time which is based on the frame rate. You could also use any number between 0 and 1 instead of using dt to determine the speed.

    So the *10 isn't correlated to the offset of 10, it's just the speed that I chose.

  • Thanks! I think I get it now. I really appreciate your help!

  • I have one more question. I just implemented slopes into my game, and when the base enemy travels up a slope, the enemies stacked on top of it don't adjust to the elevation change. Is there a way to keep the enemies a certain relative distance away from the base enemy without interfering with the falling mechanic? I tried pinning but there were issues with that.

    Thanks again

  • It would be easier if you posted your project file. Without knowing the rest of the mechanics it makes it a bit of a guessing game. There's a lot of ways to do it and a lot of things that could interfere.

  • I suspect if you wanted to continue using the current method that you could add an instance variable to the stack of enemies, something like "is on slope" then use that as a condition with something like:

    If enemy is on slope & not falling & has enemy at offset below then set enemy.Y to enemybelow.Y-100.

    EDIT: I ended up playing around with the Scene Graph tools for a bit of fun and have come up with a much more robust system. Any goombas on top of the bottom goomba automatically inherit the bottom goombas movements. This means they can travel in any direction. When a bottom goomba is destroyed, the next goomba falls to the ground and becomes the bottom goomba, which then adds any above goombas as children of it.

    1drv.ms/u/s!AkmrWgxeuxlKhIcNlIeglSsUumgCDg

  • I just took a look at it, and I think I get it. I'm going to try to implement it into my project later and see how it goes.

    One thing I don't quite get is the hierarchy reset section. If I'm understanding the pick condition right, it's looking for the distance between the bottom goomba and the top goombas, and then seeing if the distance is less than two. Isn't that distance going to always be more than two pixels though. I'm probably just seeing it wrong.

    Thanks again. This is really interesting. I'm learning a lot from it.

  • It looks for the distance between image point 1 on the bottom goomba, which is at the top of the sprite, and image point 0 on the top goomba which is at the bottom of the sprite. So they should be overlapping each other or separated by 1px based on the other rules. I had to implement this as there were problems with the pick condition when another goomba stack was overlapping on the horizontal. I've tested this system and can't get it to break.

    EDIT: Also I just noticed that in the add child action for that section the inherit Y option should be selected. It still works without it because of the other rules though but might add a layer of safety by adding it

  • Gotcha. I missed that it was comparing distance between the top image point of the bottom Goomba and the botttom image point of the top Goomba.

  • I've just had a look at it again and there are a few unnecessary things in there. Let me clean it up and I'll post it again later today. It was late last night :)

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