A waiting behind B until A moves again?

0 favourites
  • 13 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • Hello Community,

    I can't figure out a easy solution for this:

    5 Enemy's spawns behind each other.

    If the Enemy in the Front of the column stops, all enemy's behind him stops moving too.

    And if the Enemy in the front is moving again or is dead, the Enemy's behind him starting to move again.

    Is there a simple solution for this, or do I have to make like sensor for each Sprite?

    Regards

    vendara

  • You can try using Pin behavior to make the sprites trail each other, then turning on their own locomotor when the sprite they were pinned to is destroyed.

  • If you need to spawn 5 enemies each time, you could use the For event and have it repeat 5 times.

    If all enemies are only moving on a flat ground, it is quite easy, just have all of them use platform behaviour. Use a variable to determine which direction the first enemy is moving in, if it is to the left, set var to 1, to the right set var to 2. Set var to 0 to have them all stop. Than have all the other enemies movement follow the variable.

    To select the enemy at the most left or right, you can use the pick function to pick either the one closet to the left or the right edge of the screen. This way once an enemy dies, it will pick the next one closest to it, and you can apply the same var and logic to it.

  • When you say 'behind' do you mean in a line like in situation 'A' or 'B'?

  • Here is a Picture of my current stage.

    Group A Spawns at beginning,

    Group B Spawns like 30 seconds later.

    First, no Enemy should walk into another.

    So like i said at the beginning, they should all wait behind each other or move together.

    If Group A don't move anymore and Group B is catching up, they should also wait until the 1 of Group A moves again.

    Sup with that?

    Pin doesnt work, because there will be more than only one Group.

    rekjl

    This solution would work, but if 1 of Group A stops moving, Group B who is not next to Group A, will stop moving too.

    GideonG

    You can see it now at my screenshot, like Situation B, just with a Space between.

  • If you want group b to reach a certain position in relation to group a's position, the only way is to calculate that position and have group b move to it. For example, you want group b to always be 50 pixels to the left of group a. Every 0.5 seconds (use less computation power), set Variable1 to groupA.x +/- 50 (depending on whether you want it on the left or right based on group a's movement). GroupB x is not equal Variable1, groupB move to position x = variable1. You could create another variable and use the same process for groupc based on groupb, and etc

  • I hope it's not wrong to link a game from an other page here.

    But this Game is like the perfect example.

    You don't have to play long to see what i try to make.

  • Will your characters also only move in one direction? From right to left? If so, than there is a much simpler solution. Using containers as collision detection.

    Create a sprite to be used as collision detection, with the size based on how near you want the groups to be before they stop. Than use a for each event, for each group that is not overlapping that container, move left. This way, all your groups will continue to move left as long as there is not another group with its container there blocking their way.

  • Well, the character is able to walk trough the little enemys. so they should be able to turn to the right too.

  • If the character is able to walk through the enemy, than which enemy is going to be the one that moves closest to the character once it passes a few enemies.

    Example: This is the order right now

    Character - enemy a - enemy b - enemy c

    Obviously everyone follows enemy a

    Character moves and now the order is this

    enemy a - enemy b - enemy c - character

    Do they follow the previous order? Enemy a go after character with b and c behind it, or does it change order and c goes after character, b goes after c and etc?

    Character moves again and now the order is this

    enemy a - enemy b - character - enemy c

    Since your character can move past enemies, what happens in this situation?

  • Good Point.

    I didn't thought about that.

    In this case it would be more useful, if all Enemys just look at the right but don't move.

  • You mean that once your character passes your enemy, they don't move but just turn and face your character?

    If that's the case than the previous solution I mentioned, using containers and collision should work fine. Just add another condition that it will run only if character.x < enemy.x. As for facing the character, use another comparison, if character.x > enemy.x , set the enemy angle to be facing left, and if character.x < enemy.x, set the enemy angle to face right.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, it works with the Platformer behavior.

    Thanks for your help!

    [Solved]

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