Need help on recreating this movement

0 favourites
  • 4 posts
From the Asset Store
Create a boss fight with this easy to follow game pack. Recreate the classic attacks of Mutoid Man from Super Smash TV
  • Taken from my post here - viewtopic.php?f=147&t=152366&p=962278#p962278

    Hello Hello. - Would anyone be so kind as to educate me on how I would achieve this effect?

    • Subscribe to Construct videos now
      - <---- Notice the way that the little units spawn out of the buildings neatly side by side? This is what I'm trying to achieve.

    A straight up "This is how its done" would be appreciated it, but I wouldn't mind a hint in the right direction

    At the moment my units kind of just cluster all over each other and it makes it difficult to see how many are coming.

    I can't wrap my head around how I would get overlapping units to slowly spread away from each other until they are not overlapping anymore, and continue their trajectory.

    how do I tell the sprite to move away to the side that its closest to? (So it doesn't go 100 pixels to the right, when 10 pixels to the left would have accomplished it)

    I don't know the proper string to type in to do something so dynamic. The best I could come up with was

    "-1x, -1y"

    repeat until not overlapping.

    But that would cause issues if the bullets were heading towards that direction anyway and it would just accelerate them awkwardly.

    ------

    I think what I need is a way to spawn my bullets but in a spread pattern that they don't collide with each other.

    If anyone could point me towards a tutorial that handles something like this, would greatly appreciate it.

    Anything I found was relating to setting bullet angle to random to simulate shotgun spread, but that won't work so well for me I presume.

    I think I might need to create another invisible sprite in a rectangular shape of sorts, pin it to the building spawning and have it rotate towards the building being attacked.

    But I still have no idea how I would get the sprites to slowly shuffle away from each other.

    If anyone has any ideas, I would really love to hear them. This has been the only thing on my mind all week and its slowed my development to a crawl, and I'm thinking I might just forget about it and attempt it in another game, but that won't solve the issue of "I have no idea how to do this" in the first place.

  • Here's one possible idea. When you create the objects calculate their spread out position, that will be the target position. Next see if the path from the current position to the target hits any walls. If it does shift all the targets up or down depending on if they're above or below the line. Finally move toward that target and repeat next frame.

    Here's a basic example that spreads units up and down around walls.

    https://dl.dropboxusercontent.com/u/542 ... _line.capx

    Another idea would be to looking into boids or flocking behaviors.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound Thank you for input and help! This definitely helps me a lot and its pretty much what I was looking for.

    Unfortunately I am not a clever man so I'm going to be staring at your capx for quite some time trying to reverse engineer it/understand it.

    Thank you kindly, once again. I was hoping someone of your caliber would be able to help me. This is truly beautiful.

    And now I feel like i'm staring at hieroglyphics, but this will surely help me.

    Thank you.

  • Here's a simplified version. The units go around the wall when they collide with it. "Overlaps at offset" could be used to get the units to start avoiding prior to overlap. In the capx above i was checking for an overlap in the range from where the unit is to where it will be later.

    Sprites:

    "Wall"

    "Unit" with variables i, targety

    Events:

    Global number starty=240

    Start of layout

    --- unit: destroy

    Start of layout

    Repeat 10 times

    --- create unit at (0, starty)

    --- unit: set i to loopindex

    Every tick

    --- unit: set x to self.x + 100*dt

    --- unit: set targety to starty+(self.i-5)*16

    Wall: is overlapping unit

    Pick all unit

    ===unit: targety<wall.y

    --------unit: add -wall.height/2 to targety

    ===unit: targety>=wall.y

    --------unit: add wall.height/2 to targety

    Unit: y < self.targety

    --- unit: set y to self.y+100*dt

    Unit: y > self.targety

    --- unit: set y to self.y-100*dt

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